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
|
---|---|---|---|---|---|---|
__ibvs_prep_flash_access_mad(
IN ibvs_t* p_ibvs,
IN uint16_t lid,
IN uint8_t method,
IN uint16_t attr_id,
IN uint32_t attr_mod,
IN uint8_t size,
IN uint32_t data[],
IN uint32_t address,
OUT osm_madw_t **pp_madw)
{
osm_mad_addr_t mad_addr;
osm_madw_t *p_madw;
uint8_t i,dword_size;
OSM_LOG_ENTER(&(IbisObj.log));
osm_log(&(IbisObj.log), OSM_LOG_DEBUG,
"__ibvs_prep_flash_access_mad: "
" Sending VS Flash to lid:0x%04X method:0x:%X attr:0x%X mod:0x%X\n",
lid, method, attr_id, attr_mod);
dword_size = size / 4;
__ibvs_init_mad_addr(lid, &mad_addr);
p_madw = osm_mad_pool_get(
&(IbisObj.mad_pool), p_ibvs->h_bind, MAD_PAYLOAD_SIZE, &mad_addr);
*pp_madw = p_madw;
__ibvs_init_mad_hdr(method, attr_id, attr_mod, p_madw);
((ib_vs_t *)p_madw->p_mad)->vendor_key = cl_hton64(IbisObj.p_opt->v_key);
((ib_vs_flash_t *)p_madw->p_mad)->size = cl_hton32(size);
((ib_vs_flash_t *)p_madw->p_mad)->offset = cl_hton32(address);
if ((method == VENDOR_SET) || (attr_id == VS_FLASH_OPEN))
{
for (i=0;i<dword_size;i++) {
((ib_vs_flash_t *)p_madw->p_mad)->data[i] = cl_hton32(data[i]);
};
};
OSM_LOG_EXIT(&(IbisObj.log));
} | false | false | false | false | false | 0 |
maybe_end_member_template_processing (void)
{
int i;
if (!inline_parm_levels_used)
return;
--inline_parm_levels_used;
for (i = 0;
i < VARRAY_INT (inline_parm_levels, inline_parm_levels_used);
++i)
{
--processing_template_decl;
current_template_parms = TREE_CHAIN (current_template_parms);
poplevel (0, 0, 0);
}
} | false | false | false | false | false | 0 |
kill_procs(struct list_head *to_kill, int forcekill, int trapno,
int fail, struct page *page, unsigned long pfn,
int flags)
{
struct to_kill *tk, *next;
list_for_each_entry_safe (tk, next, to_kill, nd) {
if (forcekill) {
/*
* In case something went wrong with munmapping
* make sure the process doesn't catch the
* signal and then access the memory. Just kill it.
*/
if (fail || tk->addr_valid == 0) {
printk(KERN_ERR
"MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
pfn, tk->tsk->comm, tk->tsk->pid);
force_sig(SIGKILL, tk->tsk);
}
/*
* In theory the process could have mapped
* something else on the address in-between. We could
* check for that, but we need to tell the
* process anyways.
*/
else if (kill_proc(tk->tsk, tk->addr, trapno,
pfn, page, flags) < 0)
printk(KERN_ERR
"MCE %#lx: Cannot send advisory machine check signal to %s:%d\n",
pfn, tk->tsk->comm, tk->tsk->pid);
}
put_task_struct(tk->tsk);
kfree(tk);
}
} | false | false | false | false | false | 0 |
ring_test_fifo(struct test_fifo_struct *f)
{
int retval;
/*
* loops some data through the pipes to make sure they still work
*/
switch((f->flags) & O_ACCMODE) {
case O_RDONLY:
retval = write_atomic(f->rdwr_fd);
if (!retval) retval = read_atomic(f->client_fd);
break;
case O_WRONLY:
case O_RDWR:
retval = write_atomic(f->client_fd);
if (!retval) read_atomic(f->rdwr_fd);
break;
default:
retval = -1;
}
return retval;
} | false | false | false | false | false | 0 |
sgen_init_allocator (void)
{
#if defined(HAVE_KW_THREAD) && !defined(SGEN_WITHOUT_MONO)
int tlab_next_addr_offset = -1;
int tlab_temp_end_offset = -1;
MONO_THREAD_VAR_OFFSET (tlab_next_addr, tlab_next_addr_offset);
MONO_THREAD_VAR_OFFSET (tlab_temp_end, tlab_temp_end_offset);
mono_tls_key_set_offset (TLS_KEY_SGEN_TLAB_NEXT_ADDR, tlab_next_addr_offset);
mono_tls_key_set_offset (TLS_KEY_SGEN_TLAB_TEMP_END, tlab_temp_end_offset);
g_assert (tlab_next_addr_offset != -1);
g_assert (tlab_temp_end_offset != -1);
#endif
#ifdef HEAVY_STATISTICS
mono_counters_register ("# objects allocated", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_objects_alloced);
mono_counters_register ("bytes allocated", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_bytes_alloced);
mono_counters_register ("bytes allocated in LOS", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_bytes_alloced_los);
#endif
} | false | false | false | false | false | 0 |
parse_menuitem(char *buff, void *state)
{
static menu_t *menu;
menuitem_t *curitem;
ASSERT_RVAL(state != NULL, (void *) (file_skip_to_end(), NULL));
if (*buff == SPIFCONF_BEGIN_CHAR) {
menu = (menu_t *) state;
curitem = menuitem_create(NULL);
return ((void *) curitem);
}
curitem = (menuitem_t *) state;
ASSERT_RVAL(menu != NULL, state);
if (*buff == SPIFCONF_END_CHAR) {
if (!(curitem->text)) {
libast_print_error("Parse error in file %s, line %lu: Menuitem context ended with no text given. Discarding this entry.\n",
file_peek_path(), file_peek_line());
FREE(curitem);
} else {
menu_add_item(menu, curitem);
}
return ((void *) menu);
}
if (!BEG_STRCASECMP(buff, "text ")) {
char *text = spiftool_get_word(2, buff);
if (!text) {
libast_print_error("Parse error in file %s, line %lu: Missing menuitem text.\n", file_peek_path(), file_peek_line());
return ((void *) curitem);
}
menuitem_set_text(curitem, text);
FREE(text);
} else if (!BEG_STRCASECMP(buff, "rtext ")) {
char *rtext = spiftool_get_word(2, buff);
if (!rtext) {
libast_print_error("Parse error in file %s, line %lu: Missing menuitem right-justified text.\n", file_peek_path(),
file_peek_line());
return ((void *) curitem);
}
menuitem_set_rtext(curitem, rtext);
FREE(rtext);
} else if (!BEG_STRCASECMP(buff, "icon ")) {
} else if (!BEG_STRCASECMP(buff, "action ")) {
char *type = spiftool_get_pword(2, buff);
char *action = spiftool_get_word(3, buff);
if (!BEG_STRCASECMP(type, "submenu ")) {
menuitem_set_action(curitem, MENUITEM_SUBMENU, action);
} else if (!BEG_STRCASECMP(type, "string ")) {
menuitem_set_action(curitem, MENUITEM_STRING, action);
} else if (!BEG_STRCASECMP(type, "script ")) {
menuitem_set_action(curitem, MENUITEM_SCRIPT, action);
} else if (!BEG_STRCASECMP(type, "echo ")) {
menuitem_set_action(curitem, MENUITEM_ECHO, action);
} else if (!BEG_STRCASECMP(type, "separator")) {
menuitem_set_action(curitem, MENUITEM_SEP, action);
} else {
libast_print_error("Parse error in file %s, line %lu: Invalid menu item action \"%s\"\n", file_peek_path(), file_peek_line(),
NONULL(type));
}
FREE(action);
} else {
libast_print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", file_peek_path(),
file_peek_line(), buff);
}
return ((void *) curitem);
} | false | false | false | false | false | 0 |
load_file(cmd_parms *cmd, void *dummy, const char *filename)
{
apr_dso_handle_t *handle;
const char *used_file, *error;
error = dso_load(cmd, &handle, filename, &used_file);
if (error)
return error;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, APLOGNO(01576)
"loaded file %s", used_file);
return NULL;
} | false | false | false | false | true | 1 |
upack (char *buf, CheckMsg * msg, enum ck_msg_type *type)
{
char *obuf;
int nread;
if (buf == NULL)
return -1;
obuf = buf;
*type = upack_type (&buf);
check_type (*type, __FILE__, __LINE__);
upftab[*type] (&buf, msg);
nread = buf - obuf;
return nread;
} | false | false | false | false | true | 1 |
update_lcd(struct gps_data_t *gpsdata)
{
char tmpbuf[255];
char *gridsquare;
/* Get our location in Maidenhead. */
gridsquare = maidenhead(gpsdata->fix.latitude,gpsdata->fix.longitude);
/* Fill in the latitude and longitude. */
if (gpsdata->fix.mode >= MODE_2D) {
int track;
char *s;
s = deg_to_str(deg_type, fabs(gpsdata->fix.latitude));
snprintf(tmpbuf, 254, "widget_set gpsd one 1 1 {Lat: %s %c}\n", s, (gpsdata->fix.latitude < 0) ? 'S' : 'N');
send_lcd(tmpbuf);
s = deg_to_str(deg_type, fabs(gpsdata->fix.longitude));
snprintf(tmpbuf, 254, "widget_set gpsd two 1 2 {Lon: %s %c}\n", s, (gpsdata->fix.longitude < 0) ? 'W' : 'E');
send_lcd(tmpbuf);
/* As a pilot, a heading of "0" gives me the heebie-jeebies (ie, 0
== "invalid heading data", 360 == "North"). */
track=(int)(gpsdata->fix.track);
if (track == 0) track = 360;
snprintf(tmpbuf, 254, "widget_set gpsd three 1 3 {%.1f %s %d deg}\n",
gpsdata->fix.speed*speedfactor, speedunits,
track);
send_lcd(tmpbuf);
} else {
send_lcd("widget_set gpsd one 1 1 {Lat: n/a}\n");
send_lcd("widget_set gpsd two 1 2 {Lon: n/a}\n");
send_lcd("widget_set gpsd three 1 3 {n/a}\n");
}
/* Fill in the altitude and fix status. */
if (gpsdata->fix.mode == MODE_3D) {
int n;
for(n=0;n<CLIMB-2;n++) climb[n]=climb[n+1];
climb[CLIMB-1]=gpsdata->fix.climb;
avgclimb=0.0;
for(n=0;n<CLIMB;n++) avgclimb+=climb[n];
avgclimb/=CLIMB;
snprintf(tmpbuf, 254, "widget_set gpsd four 1 4 {%d %s %s %d fpm }\n",
(int)(gpsdata->fix.altitude*altfactor), altunits, gridsquare, (int)(avgclimb * METERS_TO_FEET * 60));
} else {
snprintf(tmpbuf, 254, "widget_set gpsd four 1 4 {n/a}\n");
}
send_lcd(tmpbuf);
} | false | false | false | false | false | 0 |
sas_ex_discover_devices(struct domain_device *dev, int single)
{
struct expander_device *ex = &dev->ex_dev;
int i = 0, end = ex->num_phys;
int res = 0;
if (0 <= single && single < end) {
i = single;
end = i+1;
}
for ( ; i < end; i++) {
struct ex_phy *ex_phy = &ex->ex_phy[i];
if (ex_phy->phy_state == PHY_VACANT ||
ex_phy->phy_state == PHY_NOT_PRESENT ||
ex_phy->phy_state == PHY_DEVICE_DISCOVERED)
continue;
switch (ex_phy->linkrate) {
case SAS_PHY_DISABLED:
case SAS_PHY_RESET_PROBLEM:
case SAS_SATA_PORT_SELECTOR:
continue;
default:
res = sas_ex_discover_dev(dev, i);
if (res)
break;
continue;
}
}
if (!res)
sas_check_level_subtractive_boundary(dev);
return res;
} | false | false | false | false | false | 0 |
hostname_validate (const char *hostname)
{
const char *p;
gunichar c, first_char, last_char;
p = hostname;
if (*p == '\0')
return TRUE;
do
{
/* read in a label */
c = g_utf8_get_char (p);
p = g_utf8_next_char (p);
if (!is_escalphanum (c))
return FALSE;
first_char = c;
do
{
last_char = c;
c = g_utf8_get_char (p);
p = g_utf8_next_char (p);
}
while (is_escalphanum (c) || c == '-');
if (last_char == '-')
return FALSE;
/* if that was the last label, check that it was a toplabel */
if (c == '\0' || (c == '.' && *p == '\0'))
return is_escalpha (first_char);
}
while (c == '.');
return FALSE;
} | false | false | false | false | false | 0 |
getEnvironmentVarNameByIndex(int index) const
{
if(index < 0 || index >= (int)getImpl()->env_.size()) return "";
StringMap::const_iterator iter = getImpl()->env_.begin();
for(int i = 0; i < index; ++i) ++iter;
return iter->first.c_str();
} | false | false | false | false | false | 0 |
sendResults(IDB_HANDLE ** handle, FIS_HANDLE ** fisHandle,
DMAN_HANDLE ** dmanHandle, const char *accessionNumber,
const char *studyInstanceUID,
char *requestingAETitle, char *remoteAETitle)
{
FIS_STUDYRECORD study;
FIS_RESULTSRECORD results;
CONDITION cond = 0;
FIS_INTERPRETATIONRECORD *interp;
memset(&study, 0, sizeof study);
study.Type = FIS_K_STUDY;
findStudy(handle, fisHandle, accessionNumber, studyInstanceUID, &study);
FIS_DumpRecord(&study, stdout);
findResults(fisHandle, study.StuInsUID, &results);
FIS_DumpRecord(&results, stdout);
cond = FIS_SendEvent(fisHandle, dmanHandle, FIS_K_RESULTS, &results,
FIS_K_RESULTS_CREATED, requestingAETitle, remoteAETitle);
if (cond != FIS_NORMAL) {
COND_DumpConditions();
THR_Shutdown();
exit(1);
}
interp = LST_Head(&results.InterpretationList);
LST_Position(&results.InterpretationList, interp);
while (interp != NULL) {
FIS_DumpRecord(interp, stdout);
cond = FIS_SendEvent(fisHandle, dmanHandle, FIS_K_INTERPRETATION, interp,
FIS_K_INTERPRETATION_CREATED, requestingAETitle, remoteAETitle);
if (cond != FIS_NORMAL) {
COND_DumpConditions();
THR_Shutdown();
exit(1);
}
cond = FIS_SendEvent(fisHandle, dmanHandle, FIS_K_INTERPRETATION, interp,
FIS_K_INTERPRETATION_APPROVED, requestingAETitle, remoteAETitle);
if (cond != FIS_NORMAL) {
COND_DumpConditions();
THR_Shutdown();
exit(1);
}
interp = LST_Next(&results.InterpretationList);
}
} | false | false | false | false | false | 0 |
init_child(void)
{
/* If initialization failed, there isn't much we can do. */
if (child_broken)
return;
/* Create pipes. */
if (pipe(child_outpipe) < 0) {
popup_an_errno(errno, "pipe()");
child_broken = True;
return;
}
if (pipe(child_errpipe) < 0) {
popup_an_errno(errno, "pipe()");
close(child_outpipe[0]);
close(child_outpipe[1]);
child_broken = True;
return;
}
/* Make sure their read ends are closed in child processes. */
(void) fcntl(child_outpipe[0], F_SETFD, 1);
(void) fcntl(child_errpipe[0], F_SETFD, 1);
#if defined(X3270_DISPLAY) /*[*/
/* Initialize the pop-ups. */
child_popup_init();
#endif
/* Express interest in their output. */
child_stdout.fd = child_outpipe[0];
child_stdout.input_id = AddInput(child_outpipe[0], child_output);
child_stderr.fd = child_errpipe[0];
child_stderr.input_id = AddInput(child_errpipe[0], child_error);
child_initted = True;
} | false | false | false | false | false | 0 |
zGetTBTreeNode(zTBTree *t){
zTBTreeNode* n;
t->size++;
if(t->dead_nodes == NULL){
/* if there are no dead node allocate a new node */
n = zCreateTBTreeNode();
}
else{
/* otherwise return the dead node at the start of the list */
n = t->dead_nodes;
t->dead_nodes = t->dead_nodes->child;
if(n->alive != 0){
zDie("");
}
zResetTBTreeNode(n);
}
n->tree = t;
return n;
} | false | false | false | false | false | 0 |
cmd_rename_sheet (WorkbookControl *wbc,
Sheet *sheet,
char const *new_name)
{
WorkbookSheetState *old_state;
Sheet *collision;
g_return_val_if_fail (new_name != NULL, TRUE);
g_return_val_if_fail (sheet != NULL, TRUE);
if (*new_name == 0) {
go_cmd_context_error_invalid (GO_CMD_CONTEXT (wbc), _("Name"), _("Sheet names must be non-empty."));
return TRUE;
}
collision = workbook_sheet_by_name (sheet->workbook, new_name);
if (collision && collision != sheet) {
GError *err = g_error_new (go_error_invalid(), 0,
_("A workbook cannot have two sheets with the same name."));
go_cmd_context_error (GO_CMD_CONTEXT (wbc), err);
g_error_free (err);
return TRUE;
}
old_state = workbook_sheet_state_new (sheet->workbook);
g_object_set (sheet, "name", new_name, NULL);
return cmd_reorganize_sheets (wbc, old_state, sheet);
} | false | false | false | false | false | 0 |
open_compress_pipe(const String &filename, ErrorHandler *errh)
{
StringAccum cmd;
int c = compressed_filename(filename);
switch (c) {
case COMP_COMPRESS:
cmd << "compress";
break;
case COMP_GZIP:
cmd << "gzip";
break;
case COMP_BZ2:
cmd << "bzip2";
break;
default:
errh->error("%s: unknown compression extension", filename.c_str());
errno = EINVAL;
return 0;
}
cmd << " > " << shell_quote(filename);
if (FILE *p = popen(cmd.c_str(), "w"))
return p;
else {
errh->error("%<%s%>: %s", cmd.c_str(), strerror(errno));
return 0;
}
} | false | false | false | false | false | 0 |
getFlagsByName(const char *theName, Fl_Menu_Item *currentMenu, int menuSize)
{
int i, theFlags = -1;
if (currentMenu == 0)
currentMenu = dynamicMenu;
if (menuSize == 0)
menuSize = size();
for (i = 0 ; i < menuSize ; i++)
if ((currentMenu[i].label() != 0) && (strcmp(currentMenu[i].label(), (char *)theName) == 0)) {
theFlags = currentMenu[i].flags;
break; // only change the first occurence... Normally no two menu items have the same name
}
return theFlags;
} | false | false | false | false | false | 0 |
contact_record_cb_new (ECalBackendContacts *cbc,
ECalBackendSExp *sexp,
gboolean as_string)
{
ContactRecordCB *cb_data = g_new (ContactRecordCB, 1);
cb_data->cbc = cbc;
cb_data->sexp = sexp;
cb_data->as_string = as_string;
cb_data->result = NULL;
return cb_data;
} | false | false | false | false | false | 0 |
unknownFieldMsg(emf_ObjectData_X* object_data, bool is_fatal)
{
UserInterface* gui = theControlCenter->getGui();
strstream strm;
if ( is_fatal ) {
strm << "***ERROR: Unknown field name (";
} else {
strm << "***WARNING: Unknown field name (";
}
strm << object_data->field_name
<< ") when reading object: "
<< object_data->object_name;
if ( object_data->object_id != NO_INDEX ) {
strm << " " << object_data->object_id;
}
strm << ends;
gui->showMsg(strm.str());
if (is_fatal)
return notOk;
else
return isOk;
} | false | false | false | false | false | 0 |
process_state_for_insn_equiv_partition (state_t state)
{
arc_t arc;
arc_t *insn_arcs_array = XCNEWVEC (arc_t, description->insns_num);
/* Process insns of the arcs. */
for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
insn_arcs_array [arc->insn->insn_reserv_decl->insn_num] = arc;
for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
process_insn_equiv_class (arc->insn, insn_arcs_array);
free (insn_arcs_array);
} | false | false | false | false | false | 0 |
first(RegionList *input, int num) {
/* It would be cool, if i just could truncate the input list.
* Too bad that checking for if i just could is too complicated */
RegionList *result;
ListIterator i;
Region r;
SGREPDATA(input);
result=new_region_list(sgrep);
start_region_search(input,&i);
get_region(&i,&r);
while(num>0 && r.start!=-1) {
add_region(result,r.start,r.end);
get_region(&i,&r);
num--;
}
return result;
} | false | false | false | false | false | 0 |
qexp_func_defined (Bonobo_ServerInfo * si, QueryExpr * e, QueryContext * qctx)
{
QueryExprConst retval, v1;
v1 = qexp_evaluate (si, e->u.function_value.arguments->data, qctx);
retval.value_known = TRUE;
retval.type = CONST_BOOLEAN;
retval.u.v_boolean = v1.value_known ? TRUE : FALSE;
retval.needs_free = FALSE;
qexp_constant_unuse (v1);
return retval;
} | false | false | false | false | false | 0 |
AssGVar (
UInt gvar,
Obj val )
{
Obj cops; /* list of internal copies */
Obj * copy; /* one copy */
UInt i; /* loop variable */
Char * name; /* name of a function */
Obj onam; /* object of <name> */
Int len; /* length of string */
/* make certain that the variable is not read only */
while ( (REREADING != True) &&
(ELM_PLIST( WriteGVars, gvar ) == INTOBJ_INT(0)) ) {
ErrorReturnVoid(
"Variable: '%s' is read only",
(Int)CSTR_STRING( ELM_PLIST(NameGVars,gvar) ), 0L,
"you can 'return;' after making it writable" );
}
/* assign the value to the global variable */
VAL_GVAR(gvar) = val;
CHANGED_BAG( ValGVars );
/* if the global variable was automatic, convert it to normal */
SET_ELM_PLIST( ExprGVars, gvar, 0 );
/* assign the value to all the internal copies */
cops = ELM_PLIST( CopiesGVars, gvar );
if ( cops != 0 ) {
for ( i = 1; i <= LEN_PLIST(cops); i++ ) {
copy = (Obj*) ELM_PLIST(cops,i);
*copy = val;
}
}
/* if the value is a function, assign it to all the internal fopies */
cops = ELM_PLIST( FopiesGVars, gvar );
if ( cops != 0 && val != 0 && TNUM_OBJ(val) == T_FUNCTION ) {
for ( i = 1; i <= LEN_PLIST(cops); i++ ) {
copy = (Obj*) ELM_PLIST(cops,i);
*copy = val;
}
}
/* if the values is not a function, assign the error function */
else if ( cops != 0 && val != 0 /* && TNUM_OBJ(val) != T_FUNCTION */ ) {
for ( i = 1; i <= LEN_PLIST(cops); i++ ) {
copy = (Obj*) ELM_PLIST(cops,i);
*copy = ErrorMustEvalToFuncFunc;
}
}
/* if this was an unbind, assign the other error function */
else if ( cops != 0 /* && val == 0 */ ) {
for ( i = 1; i <= LEN_PLIST(cops); i++ ) {
copy = (Obj*) ELM_PLIST(cops,i);
*copy = ErrorMustHaveAssObjFunc;
}
}
/* assign name to a function */
if ( val != 0 && TNUM_OBJ(val) == T_FUNCTION && NAME_FUNC(val) == 0 ) {
name = NameGVar(gvar);
/*CCC onam = NEW_STRING(strlen(name));
SyStrncat( CSTR_STRING(onam), name, strlen(name) ); CCC*/
len = strlen(name);
C_NEW_STRING(onam, len, name);
RESET_FILT_LIST( onam, FN_IS_MUTABLE );
NAME_FUNC(val) = onam;
CHANGED_BAG(val);
}
} | false | false | false | false | false | 0 |
fillBuf(int pos, int len) {
int c;
if (pos < 0 || len < 0 || len > (int)sizeof(buf) ||
pos > INT_MAX - (int)sizeof(buf)) {
return gFalse;
}
if (pos < bufPos) {
return gFalse;
}
// if requested region will not fit in the current buffer...
if (pos + len > bufPos + (int)sizeof(buf)) {
// if the start of the requested data is already in the buffer, move
// it to the start of the buffer
if (pos < bufPos + bufLen) {
bufLen -= pos - bufPos;
memmove(buf, buf + (pos - bufPos), bufLen);
bufPos = pos;
// otherwise discard data from the
// stream until we get to the requested position
} else {
bufPos += bufLen;
bufLen = 0;
while (bufPos < pos) {
if ((c = (*getChar)(data)) < 0) {
return gFalse;
}
++bufPos;
}
}
}
// read the rest of the requested data
while (bufPos + bufLen < pos + len) {
if ((c = (*getChar)(data)) < 0) {
return gFalse;
}
buf[bufLen++] = (char)c;
}
return gTrue;
} | false | false | false | false | false | 0 |
tn3270e_request(void)
{
int tt_len, tb_len;
char *tt_out;
char *t;
tt_len = strlen(termtype);
if (try_lu != CN && *try_lu)
tt_len += strlen(try_lu) + 1;
tb_len = 5 + tt_len + 2;
tt_out = Malloc(tb_len + 1);
t = tt_out;
t += sprintf(tt_out, "%c%c%c%c%c%s",
IAC, SB, TELOPT_TN3270E, TN3270E_OP_DEVICE_TYPE,
TN3270E_OP_REQUEST, termtype);
/* Convert 3279 to 3278, per the RFC. */
if (tt_out[12] == '9')
tt_out[12] = '8';
if (try_lu != CN && *try_lu)
t += sprintf(t, "%c%s", TN3270E_OP_CONNECT, try_lu);
(void) sprintf(t, "%c%c", IAC, SE);
net_rawout((unsigned char *)tt_out, tb_len);
trace_dsn("SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s "
"%s\n",
cmd(SB), opt(TELOPT_TN3270E), (int)strlen(termtype), tt_out + 5,
(try_lu != CN && *try_lu) ? " CONNECT " : "",
(try_lu != CN && *try_lu) ? try_lu : "",
cmd(SE));
Free(tt_out);
} | false | false | false | false | false | 0 |
table_share_hash_get_key(const uchar *entry, size_t *length,
my_bool)
{
const PFS_table_share * const *typed_entry;
const PFS_table_share *share;
const void *result;
typed_entry= reinterpret_cast<const PFS_table_share* const *> (entry);
DBUG_ASSERT(typed_entry != NULL);
share= *typed_entry;
DBUG_ASSERT(share != NULL);
*length= share->m_key.m_key_length;
result= &share->m_key.m_hash_key[0];
return const_cast<uchar*> (reinterpret_cast<const uchar*> (result));
} | false | false | false | false | false | 0 |
gda_models_provider_open_connection (GdaServerProvider *provider, GdaConnection *cnc,
GdaQuarkList *params, G_GNUC_UNUSED GdaQuarkList *auth,
G_GNUC_UNUSED guint *task_id, GdaServerProviderAsyncCallback async_cb,
G_GNUC_UNUSED gpointer cb_data)
{
g_return_val_if_fail (GDA_IS_MODELS_PROVIDER (provider), FALSE);
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
/* Don't allow asynchronous connection opening for virtual providers */
if (async_cb) {
gda_connection_add_event_string (cnc, _("Provider does not support asynchronous connection open"));
return FALSE;
}
/* Check for connection parameters */
/* TO_ADD: your own connection parameters */
const gchar *db_name;
db_name = gda_quark_list_find (params, "DB_NAME");
if (!db_name) {
gda_connection_add_event_string (cnc,
_("The connection string must contain the DB_NAME value"));
return FALSE;
}
/* create GdaDataModelModels object, only one show here
* If the data model(s) can not be created at this time, then it is possible to still declare the
* table(s) for which the data model(s) will be created only when the table(s) are accessed
*/
GdaDataModel *model;
model = NULL; TO_IMPLEMENT;
/* open virtual connection */
if (! GDA_SERVER_PROVIDER_CLASS (parent_class)->open_connection (GDA_SERVER_PROVIDER (provider), cnc, params,
NULL, NULL, NULL, NULL)) {
gda_connection_add_event_string (cnc, _("Can't open virtual connection"));
return FALSE;
}
/* add the data model(s) as table(s) */
GError *error = NULL;
if (!gda_vconnection_data_model_add_model (GDA_VCONNECTION_DATA_MODEL (cnc), model, "a_table", &error)) {
gda_connection_add_event_string (cnc,
_("Could not add data model to connection: %s"),
error && error->message ? error->message : _("no detail"));
g_error_free (error);
gda_connection_close_no_warning (cnc);
g_object_unref (model);
return FALSE;
}
else {
/* set associated data to the virtual connection */
ModelsConnectionData *cdata;
cdata = g_new0 (ModelsConnectionData, 1);
TO_IMPLEMENT;
gda_virtual_connection_internal_set_provider_data (GDA_VIRTUAL_CONNECTION (cnc),
cdata, (GDestroyNotify) gda_models_free_cnc_data);
}
return TRUE;
} | false | false | false | false | false | 0 |
pm80x_deinit(void)
{
/*
* workaround: clear the dependency between pm800 and pm805.
* would remove it after HW chip fixes the issue.
*/
if (g_pm80x_chip->companion)
g_pm80x_chip->companion = NULL;
else
g_pm80x_chip = NULL;
return 0;
} | false | false | false | false | false | 0 |
sbitmap_zero (sbitmap bmap)
{
memset (bmap->elms, 0, SBITMAP_SIZE_BYTES (bmap));
if (bmap->popcount)
memset (bmap->popcount, 0, bmap->size * sizeof (unsigned char));
} | false | false | false | false | false | 0 |
wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain)
{
struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
pi->sh->phytxchain = txchain;
if (ISNPHY(pi))
wlc_phy_rxcore_setstate_nphy(pih, rxchain);
pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain);
} | false | false | false | false | false | 0 |
fetchSvAttrib(SV *attribs, char *key) {
dTHX;
if (attribs) {
SV **svp;
if ((svp = hv_fetch((HV*) SvRV(attribs), key, strlen(key), 0)) != NULL) {
return newSVsv(*svp);
}
}
return NULL;
} | false | false | false | false | false | 0 |
purchase_dlg_reset( PurchaseDlg *pdlg )
{
lbox_set_items( pdlg->nation_lbox, get_purchase_nations() );
lbox_set_items( pdlg->uclass_lbox, get_purchase_unit_classes() );
pdlg->cur_nation = lbox_select_first_item( pdlg->nation_lbox );
if (pdlg->cur_nation == NULL) /* list box empty */
pdlg->cur_nation = cur_player->nations[0];
pdlg->cur_uclass = lbox_select_first_item( pdlg->uclass_lbox );
if (pdlg->cur_uclass == NULL) /* list box empty */
pdlg->cur_uclass = &unit_classes[0];
pdlg->trsp_uclass = get_purchase_trsp_class();
pdlg->cur_unit_limit = player_get_purchase_unit_limit( cur_player );
lbox_set_items( pdlg->reinf_lbox, get_reinf_units() );
update_purchasable_units(pdlg);
update_purchase_unit_limit(pdlg, 0);
} | false | false | false | false | false | 0 |
ircd_running (void)
{
int pid;
if (file_exists(IRCDPID_PATH)) {
pid = read_pid(IRCDPID_PATH);
if (pid > 0) {
return(verify_pid(pid) == 1);
} else {
return(-1);
}
}
return(0);
} | false | false | false | false | false | 0 |
finishpcall (lua_State *L, int status, lua_KContext extra) {
if (status != LUA_OK && status != LUA_YIELD) { /* error? */
lua_pushboolean(L, 0); /* first result (false) */
lua_pushvalue(L, -2); /* error message */
return 2; /* return false, msg */
}
else
return lua_gettop(L) - (int)extra; /* return all results */
} | false | false | false | false | false | 0 |
libeval_25add_load_path(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_)
{
ScmObj path_scm;
const char * path;
ScmObj afterp_scm;
ScmObj afterp;
ScmObj SCM_SUBRARGS[3];
int SCM_i;
SCM_ENTER_SUBR("%add-load-path");
if (SCM_ARGCNT >= 3
&& !SCM_NULLP(SCM_ARGREF(SCM_ARGCNT-1)))
Scm_Error("too many arguments: up to 2 is expected, %d given.", SCM_ARGCNT + Scm_Length(SCM_ARGREF(SCM_ARGCNT-1)) - 1);
for (SCM_i=0; SCM_i<3; SCM_i++) {
SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
}
path_scm = SCM_SUBRARGS[0];
if (!SCM_STRINGP(path_scm)) Scm_Error("const C string required, but got %S", path_scm);
path = SCM_STRING_CONST_CSTRING(path_scm);
if (SCM_ARGCNT > 1+1) {
afterp_scm = SCM_SUBRARGS[1];
} else {
afterp_scm = SCM_UNBOUND;
}
afterp = (afterp_scm);
{
{
ScmObj SCM_RESULT;
#line 120 "libeval.scm"
SCM_RESULT=(Scm_AddLoadPath(path,!(SCM_FALSEP(afterp))));
SCM_RETURN(SCM_OBJ_SAFE(SCM_RESULT));
}
}
} | false | false | false | false | false | 0 |
g_time_format (struct tm *self, const gchar* format) {
gchar* result = NULL;
gchar* _tmp0_ = NULL;
gchar* buffer;
gint buffer_length1;
gint _buffer_size_;
gchar* _tmp1_;
gint _tmp1__length1;
const gchar* _tmp2_;
gchar* _tmp3_;
gint _tmp3__length1;
gchar* _tmp4_;
g_return_val_if_fail (format != NULL, NULL);
_tmp0_ = g_new0 (gchar, 64);
buffer = _tmp0_;
buffer_length1 = 64;
_buffer_size_ = buffer_length1;
_tmp1_ = buffer;
_tmp1__length1 = buffer_length1;
_tmp2_ = format;
strftime (_tmp1_, _tmp1__length1, _tmp2_, &(*self));
_tmp3_ = buffer;
_tmp3__length1 = buffer_length1;
_tmp4_ = g_strdup ((const gchar*) _tmp3_);
result = _tmp4_;
buffer = (g_free (buffer), NULL);
return result;
} | false | false | false | false | false | 0 |
pf_key_v2_register_sa_seq(u_int8_t *spi, size_t sz, u_int8_t proto,
struct sockaddr *dst, int dstlen, u_int32_t seq)
{
struct pf_key_v2_sa_seq *node = 0;
node = malloc(sizeof *node);
if (!node)
goto cleanup;
memset(node, '0', sizeof *node);
node->spi = malloc(sz);
if (!node->spi)
goto cleanup;
node->dst = malloc(sysdep_sa_len(dst));
if (!node->dst)
goto cleanup;
memcpy(node->dst, dst, sysdep_sa_len(dst));
node->dstlen = sysdep_sa_len(dst);
memcpy(node->spi, spi, sz);
node->sz = sz;
node->proto = proto;
node->seq = seq;
TAILQ_INSERT_TAIL(&pf_key_v2_sa_seq_map, node, link);
return 1;
cleanup:
if (node->dst)
free(node->dst);
if (node)
free(node);
return 0;
} | false | true | false | true | false | 1 |
trackpoint_write(struct ps2dev *ps2dev,
unsigned char loc, unsigned char val)
{
if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) ||
ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) ||
ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) ||
ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, val))) {
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
IoMessage_assertArgCount_receiver_(IoMessage *self, int n, IoObject *receiver)
{
if (List_size(DATA(self)->args) < n)
{
IoState_error_(IOSTATE, self, "[%s %s] requires %i arguments\n",
IoObject_name(receiver), CSTRING(DATA(self)->name), n);
}
} | false | false | false | false | false | 0 |
arm_split_compare_and_swap (rtx operands[])
{
rtx rval, mem, oldval, newval, scratch;
enum machine_mode mode;
enum memmodel mod_s, mod_f;
bool is_weak;
rtx label1, label2, x, cond;
rval = operands[0];
mem = operands[1];
oldval = operands[2];
newval = operands[3];
is_weak = (operands[4] != const0_rtx);
mod_s = (enum memmodel) INTVAL (operands[5]);
mod_f = (enum memmodel) INTVAL (operands[6]);
scratch = operands[7];
mode = GET_MODE (mem);
arm_pre_atomic_barrier (mod_s);
label1 = NULL_RTX;
if (!is_weak)
{
label1 = gen_label_rtx ();
emit_label (label1);
}
label2 = gen_label_rtx ();
arm_emit_load_exclusive (mode, rval, mem);
cond = arm_gen_compare_reg (NE, rval, oldval, scratch);
x = gen_rtx_NE (VOIDmode, cond, const0_rtx);
x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
gen_rtx_LABEL_REF (Pmode, label2), pc_rtx);
emit_unlikely_jump (gen_rtx_SET (VOIDmode, pc_rtx, x));
arm_emit_store_exclusive (mode, scratch, mem, newval);
/* Weak or strong, we want EQ to be true for success, so that we
match the flags that we got from the compare above. */
cond = gen_rtx_REG (CCmode, CC_REGNUM);
x = gen_rtx_COMPARE (CCmode, scratch, const0_rtx);
emit_insn (gen_rtx_SET (VOIDmode, cond, x));
if (!is_weak)
{
x = gen_rtx_NE (VOIDmode, cond, const0_rtx);
x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
gen_rtx_LABEL_REF (Pmode, label1), pc_rtx);
emit_unlikely_jump (gen_rtx_SET (VOIDmode, pc_rtx, x));
}
if (mod_f != MEMMODEL_RELAXED)
emit_label (label2);
arm_post_atomic_barrier (mod_s);
if (mod_f == MEMMODEL_RELAXED)
emit_label (label2);
} | false | false | false | false | false | 0 |
lrc_attr_add(CONNECTION *c, DBH *dbh, char **arglist)
{
int rc;
globus_rls_attr_type_t atype;
char *val;
if (!arglist[0] || !arglist[1] || !arglist[2] || !arglist[3]) {
rrpc_error(c, GLOBUS_RLS_BADARG, "");
return;
}
atype = atoi(arglist[2]);
if (atype == globus_rls_attr_type_str && !arglist[4])
val = "";
else
val = arglist[4];
if ((rc = db_attr_add(dbh->lrc, arglist[0], atoi(arglist[1]), atype,
arglist[3], val, c->errmsg)) != GLOBUS_RLS_SUCCESS) {
rrpc_error(c, rc, "%s", c->errmsg);
return;
}
rrpc_success(c);
} | false | false | false | false | false | 0 |
menubar_visible_changed(property_t prop)
{
GtkWidget *widget;
gboolean visible;
widget = gui_main_window_lookup("menu_menubar_visible");
gui_prop_get_boolean_val(prop, &visible);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), visible);
widget = gui_main_window_lookup("menubar_main");
/*
* The menubar is not hidden but shrunk to a single pixel in height
* so that the accelerator keys (like Control-Q) are still functional.
*/
if (visible) {
gtk_widget_set_size_request(widget, -1, -1);
} else {
/* 1 pixel is the smallest size, 0 means "as small as possible" */
gtk_widget_set_size_request(widget, -1, 1);
}
return FALSE;
} | false | false | false | false | false | 0 |
add_account_verbose(char *contact, eb_account *ea, int verbosity)
{
struct relocate_account_data *rad;
struct contact *c = find_contact_by_nick(contact);
eb_account *account;
if (ea->ela)
account = find_account_with_ela(ea->handle, ea->ela);
else
account = find_account_by_handle(ea->handle, ea->service_id);
if (account) {
if (!strcasecmp(account->account_contact->group->name,
_("Unknown"))
|| strstr(account->account_contact->group->name,
"__Ayttm_Dummy_Group__")
== account->account_contact->group->name) {
move_account(c, account);
} else {
char buff[2048];
snprintf(buff, sizeof(buff),
_("The account \"%s\" already exists on your\n"
"contact list at the following location\n"
"\tGroup: %s\n"
"\tContact: %s\n"
"\nShould I move it?"),
account->handle,
account->account_contact->group->name,
account->account_contact->nick);
/* remove this contact if it was newly created */
if (verbosity) {
rad = calloc(1,
sizeof(struct relocate_account_data));
rad->account = account;
rad->contact = c;
eb_do_dialog(buff, _("Error: account exists"),
move_account_yn, rad);
} else if (c && l_list_empty(c->accounts))
remove_contact(c);
}
return;
}
if (!find_suitable_local_account_for_remote(ea, NULL)) {
contact_mgmt_queue_add(ea, MGMT_ADD,
c ? c->group->name : _("Unknown"));
}
if (c) {
c->accounts =
l_list_insert_sorted(c->accounts, ea, account_cmp);
ea->account_contact = c;
RUN_SERVICE(ea)->add_user(ea);
if (!strcmp(c->group->name, _("Ignore")) &&
RUN_SERVICE(ea)->ignore_user)
RUN_SERVICE(ea)->ignore_user(ea);
} else
add_unknown_with_name(ea, contact);
update_contact_list();
write_contact_list();
} | false | false | false | false | false | 0 |
denali_irq_init(struct denali_nand_info *denali)
{
uint32_t int_mask;
int i;
/* Disable global interrupts */
denali_set_intr_modes(denali, false);
int_mask = DENALI_IRQ_ALL;
/* Clear all status bits */
for (i = 0; i < denali->max_banks; ++i)
iowrite32(0xFFFF, denali->flash_reg + INTR_STATUS(i));
denali_irq_enable(denali, int_mask);
} | false | false | false | false | false | 0 |
idxFirst(Cursor & cur) const
{
switch (v_align_) {
case 't':
cur.idx() = 0;
break;
case 'b':
cur.idx() = (nrows() - 1) * ncols();
break;
default:
cur.idx() = ((nrows() - 1) / 2) * ncols();
}
cur.pos() = 0;
return true;
} | false | false | false | false | false | 0 |
folder_set_message_flags (CamelFolder *folder,
const gchar *uid,
CamelMessageFlags flags,
CamelMessageFlags set)
{
CamelMessageInfo *info;
gint res;
g_return_val_if_fail (folder->summary != NULL, FALSE);
info = camel_folder_summary_get (folder->summary, uid);
if (info == NULL)
return FALSE;
res = camel_message_info_set_flags (info, flags, set);
camel_message_info_free (info);
return res;
} | false | false | false | false | false | 0 |
write_internal_format(FILE *out) {
pos_format = PSEDIT_POS_FORMAT;
size_format = PSEDIT_SIZE_FORMAT;
color_format = PSEDIT_COLOR_FORMAT;
text_format = PSEDIT_TEXT_FORMAT_PRINT;
glyph_format = PSEDIT_GLYPH_FORMAT;
tag_format = PSEDIT_TAG_FORMAT;
for (int i = 1; i < pse->get_max_pages(); i++) {
if (pse->get_text(i)) {
fprintf(out, PSEDIT_PAGE_FORMAT, i);
write_text(out, pse->get_text(i));
}
}
} | false | false | false | false | false | 0 |
handleFightSocket()
{
switch( _socket->getCla2() ) {
case C_FIGHT_INIT:
handleInit();
break;
case C_FIGHT_CREATURE:
break;
case C_FIGHT_LORD:
handleOpponent();
break;
case C_FIGHT_CELL:
handleCell();
break;
case C_FIGHT_UNIT:
handleNewUnit();
break;
case C_FIGHT_MODUNIT:
break;
case C_FIGHT_MOVE:
handleMove();
break;
case C_FIGHT_ENDMOVE:
break;
case C_FIGHT_ACTIVE:
handleActive();
break;
case C_FIGHT_DISTATTACK:
break;
case C_FIGHT_WAIT:
break;
case C_FIGHT_FLEE:
break;
case C_FIGHT_DEFEND:
break;
case C_FIGHT_DAMAGE:
handleDamage();
break;
case C_FIGHT_END:
if(!_isCreature){
updateUnits();
}
break;
}
} | false | false | false | false | false | 0 |
k_bc_init
(enum blockcipher_e cipher)
{
enum k_error_e err = K_ESUCCESS;
struct k_bc_t* c = 0;
c = k_calloc(1, sizeof(struct k_bc_t));
if (!c) {
err = K_ENOMEM;
goto k_bcmode_init_err;
}
c->blockcipher = bc_get_by_id(cipher);
if (!c->blockcipher) {
err = K_ENOCIPHER;
goto k_bcmode_init_err;
}
if (!c->blockcipher->schedule_size) {
err = K_ESCHEDZERO;
goto k_bcmode_init_err;
}
c->schedule = k_locked_calloc(1, c->blockcipher->schedule_size,
&c->alloced_schedsize);
if (!c->schedule) {
err = K_ENOMEM;
goto k_bcmode_init_err;
}
if (k_bcmode_set_mode(c, BLK_CIPHER_MODE_NOOP, -1))
goto k_bcmode_init_err;
return c;
k_bcmode_init_err:
k_bc_finish(c);
k_error(err);
return NULL;
} | false | false | false | false | false | 0 |
oss_getattro(oss_audio_t *self, PyObject *nameobj)
{
char *name = "";
PyObject * rval = NULL;
if (PyUnicode_Check(nameobj))
name = _PyUnicode_AsString(nameobj);
if (strcmp(name, "closed") == 0) {
rval = (self->fd == -1) ? Py_True : Py_False;
Py_INCREF(rval);
}
else if (strcmp(name, "name") == 0) {
rval = PyUnicode_FromString(self->devicename);
}
else if (strcmp(name, "mode") == 0) {
/* No need for a "default" in this switch: from newossobject(),
self->mode can only be one of these three values. */
switch(self->mode) {
case O_RDONLY:
rval = PyUnicode_FromString("r");
break;
case O_RDWR:
rval = PyUnicode_FromString("rw");
break;
case O_WRONLY:
rval = PyUnicode_FromString("w");
break;
}
}
else {
rval = PyObject_GenericGetAttr((PyObject *)self, nameobj);
}
return rval;
} | false | false | false | false | false | 0 |
command_pause (int unitnum, int paused)
{
struct cdunit *cdu = unitisopen (unitnum);
if (!cdu)
return -1;
int old = cdu->cdda_paused;
cdu->cdda_paused = paused;
return old;
} | false | false | false | false | false | 0 |
getDescendantIndexes(const QModelIndex &parent)
{
QModelIndexList list;
const int column = 0;
for(int row = 0; row < m_model->rowCount(parent); ++row)
{
QModelIndex idx = m_model->index(row, column, parent);
list << idx;
list << getDescendantIndexes(idx);
}
return list;
} | false | false | false | false | false | 0 |
eio_dent_cmp (const eio_dirent *a, const eio_dirent *b)
{
return a->score - b->score ? a->score - b->score /* works because our signed char is always 0..100 */
: a->inode < b->inode ? -1
: a->inode > b->inode ? 1
: 0;
} | false | false | false | false | false | 0 |
List(const char* PluginID, const char* param, ostream* os)
{
vector<string> vlist;
if(!ListAsVector(PluginID,param, vlist))
*os << PluginID << " is not a recognized plugin type. Those with instances of sub-types loaded are:" << endl;
copy(vlist.begin(), vlist.end(), std::ostream_iterator<string>(*os, "\n"));
} | false | false | false | false | false | 0 |
f_printf(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
#ifdef HAVE_STDARG_H /* only very old compilers can't do this */
{
char_u buf[NUMBUFLEN];
int len;
char_u *s;
int saved_did_emsg = did_emsg;
char *fmt;
/* Get the required length, allocate the buffer and do it for real. */
did_emsg = FALSE;
fmt = (char *)get_tv_string_buf(&argvars[0], buf);
len = vim_vsnprintf(NULL, 0, fmt, ap, argvars + 1);
if (!did_emsg)
{
s = alloc(len + 1);
if (s != NULL)
{
rettv->vval.v_string = s;
(void)vim_vsnprintf((char *)s, len + 1, fmt, ap, argvars + 1);
}
}
did_emsg |= saved_did_emsg;
}
#endif
} | false | false | false | false | false | 0 |
mx_window_allocation_changed_cb (ClutterActor *actor,
ClutterActorBox *box,
ClutterAllocationFlags flags,
MxWindow *window)
{
MxPadding padding;
gboolean from_toolbar;
MxWindowPrivate *priv;
gfloat x, y, width, height, toolbar_height, stage_width, stage_height;
/* Note, ideally this would happen just before allocate, but there's
* no signal we can connect to for that without overriding an actor.
*
* Instead, we do this each time the allocation is changed on the stage
* or the toolbar. This shouldn't be a frequent occurence, but
* unfortunately can happen multiple times before the actual relayout
* happens.
*/
priv = window->priv;
from_toolbar = (actor == priv->toolbar);
actor = priv->stage;
mx_window_get_size (window, &width, &height);
clutter_actor_get_size (actor, &stage_width, &stage_height);
x = (stage_width - width) / 2.f;
y = (stage_height - height) / 2.f;
if (!priv->has_toolbar || priv->small_screen || priv->fullscreen)
padding.top = padding.right = padding.bottom = padding.left = 0;
else
padding.top = padding.right = padding.bottom = padding.left = 1;
if (priv->has_toolbar && priv->toolbar)
{
clutter_actor_get_preferred_height (priv->toolbar,
width - padding.left -
padding.right,
NULL, &toolbar_height);
if (!from_toolbar)
{
clutter_actor_set_position (priv->toolbar,
padding.left + x,
padding.top + y);
clutter_actor_set_rotation (priv->toolbar,
CLUTTER_Z_AXIS,
priv->angle,
width / 2.f - padding.left,
height / 2.f - padding.top, 0);
g_object_set (G_OBJECT (priv->toolbar),
"natural-width",
width - padding.left - padding.right,
NULL);
}
}
else
{
toolbar_height = 0;
}
if (priv->child)
{
g_object_set (G_OBJECT (priv->child),
"natural-width", width - padding.left - padding.right,
"natural-height", height - toolbar_height -
padding.top - padding.bottom,
"x", padding.left + x,
"y", toolbar_height + padding.top + y,
NULL);
clutter_actor_set_rotation (priv->child,
CLUTTER_Z_AXIS,
priv->angle,
width / 2.f - padding.left,
height / 2.f - padding.top - toolbar_height,
0);
}
if (priv->resize_grip)
{
clutter_actor_get_preferred_size (priv->resize_grip,
NULL, NULL,
&width, &height);
clutter_actor_set_position (priv->resize_grip,
stage_width - width - padding.right,
stage_height - height - padding.bottom);
}
} | false | false | false | false | false | 0 |
SetConfigDefaults(int bSet)
{
int i;
void *var_ptr = NULL;
for(i = 0; ConfigVars[i].var_name[0] != 0; i++) {
if(strcmp(ConfigVars[i].var_type,"%s") == 0) {
if(ConfigVars[i].Flags & CON_FLG_BASED_VAR) {
if(ConfigPass == 0) {
// Prior to first pass, class variables haven't been created yet
continue;
}
}
else {
var_ptr = ConfigVars[i].var_ptr;
}
if(*((char **) var_ptr) != NULL)
{
free(*((char **) var_ptr));
*((char **) var_ptr) = NULL;
}
}
else if(strcmp(ConfigVars[i].var_type,"%F") == 0) {
if(!(ConfigVars[i].Flags & CON_FLG_BASED_VAR)) {
ConfigVars[i].AccessFunc(&ConfigVars[i],NULL,AF_SET_DEFAULT,0);
}
}
}
if(bSet) {
ConferenceID = strdup(PACKAGE " V " VERSION);
DirServerHost[0] = strdup("server1.echolink.org");
AppName = strdup("tlb");
RunDir = strdup("/var/run/");
}
} | false | false | false | true | false | 1 |
gst_avdtp_sink_start(GstBaseSink *basesink)
{
GstAvdtpSink *self = GST_AVDTP_SINK(basesink);
gint sk;
gint err;
GST_INFO_OBJECT(self, "start");
self->data = g_new0(struct bluetooth_data, 1);
self->stream = NULL;
self->stream_caps = NULL;
self->mp3_using_crc = -1;
self->channel_mode = -1;
if (self->transport != NULL)
return gst_avdtp_sink_transport_get_properties(self);
self->watch_id = 0;
sk = bt_audio_service_open();
if (sk < 0) {
err = -errno;
GST_ERROR_OBJECT(self, "Cannot open connection to bt "
"audio service: %s %d", strerror(-err), -err);
return FALSE;
}
self->server = g_io_channel_unix_new(sk);
g_io_channel_set_encoding(self->server, NULL, NULL);
self->watch_id = g_io_add_watch(self->server, G_IO_HUP | G_IO_ERR |
G_IO_NVAL, server_callback, self);
if (!gst_avdtp_sink_get_capabilities(self)) {
GST_ERROR_OBJECT(self, "failed to get capabilities "
"from device");
goto failed;
}
return TRUE;
failed:
bt_audio_service_close(sk);
return FALSE;
} | false | false | false | false | false | 0 |
ptaGetLinearLSF(PTA *pta,
l_float32 *pa,
l_float32 *pb,
NUMA **pnafit)
{
l_int32 n, i;
l_float32 factor, sx, sy, sxx, sxy, val;
l_float32 *xa, *ya;
PROCNAME("ptaGetLinearLSF");
if (!pta)
return ERROR_INT("pta not defined", procName, 1);
if (!pa && !pb)
return ERROR_INT("&a and/or &b not defined", procName, 1);
if (pa) *pa = 0.0;
if (pb) *pb = 0.0;
if ((n = ptaGetCount(pta)) < 2)
return ERROR_INT("less than 2 pts not found", procName, 1);
xa = pta->x; /* not a copy */
ya = pta->y; /* not a copy */
sx = sy = sxx = sxy = 0.;
if (pa && pb) {
for (i = 0; i < n; i++) {
sx += xa[i];
sy += ya[i];
sxx += xa[i] * xa[i];
sxy += xa[i] * ya[i];
}
factor = n * sxx - sx * sx;
if (factor == 0.0)
return ERROR_INT("no solution found", procName, 1);
factor = 1. / factor;
*pa = factor * ((l_float32)n * sxy - sx * sy);
*pb = factor * (sxx * sy - sx * sxy);
}
else if (pa) { /* line through origin */
for (i = 0; i < n; i++) {
sxx += xa[i] * xa[i];
sxy += xa[i] * ya[i];
}
if (sxx == 0.0)
return ERROR_INT("no solution found", procName, 1);
*pa = sxy / sxx;
}
else { /* a = 0; horizontal line */
for (i = 0; i < n; i++)
sy += ya[i];
*pb = sy / (l_float32)n;
}
if (pnafit) {
*pnafit = numaCreate(n);
for (i = 0; i < n; i++) {
val = (*pa) * xa[i] + *pb;
numaAddNumber(*pnafit, val);
}
}
return 0;
} | false | false | false | true | false | 1 |
vlog_msgf(int fd, int lf, const char* fmt, va_list ap, int with_errno)
{
int level = LOG_PRI(lf);
char buf[1024];
if (level_ < level)
{
return 0;
}
if (fd > -1)
{
if (dprintf(fd, "%s;", flty_[level]) < 0)
{
return -1;
}
if (vdprintf(fd, fmt, ap) < 0)
{
return -1;
}
if (with_errno)
{
if (dprintf(fd, " (%s)", strerror(errno)) < 0)
{
return -1;
}
}
if (dprintf(fd, "\n") < 0)
{
return -1;
}
}
else
{
if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0)
{
return -1;
}
syslog(level | LOG_DAEMON, "%s", buf);
}
return 0;
} | true | true | false | false | true | 1 |
es_ttf_renderUTF8Shaded(sdl_data *sd, int len, char *buff)
{
char *text, *bp, *start;
int sendlen;
TTF_Font *font;
SDL_Surface *surface;
SDL_Color fgcolor, bgcolor;
bp = buff;
// read input
// note: note: see note on parameter ordering in es_ttf_renderTextSolid
POPGLPTR(font, bp);
fgcolor.r = get8(bp);
fgcolor.g = get8(bp);
fgcolor.b = get8(bp);
bgcolor.r = get8(bp);
bgcolor.g = get8(bp);
bgcolor.b = get8(bp);
text = bp;
// render text
surface = TTF_RenderUTF8_Shaded(font, text, fgcolor, bgcolor);
// return a surface pointer
bp = start = sdl_get_temp_buff(sd, 8);
PUSHGLPTR(surface, bp);
sendlen = bp - start;
sdl_send(sd, sendlen);
} | false | false | false | false | true | 1 |
screenshot_save_to_file (ScreenshotApplication *self)
{
GFile *target_file;
if (self->priv->dialog != NULL)
screenshot_dialog_set_busy (self->priv->dialog, TRUE);
target_file = g_file_new_for_uri (self->priv->save_uri);
if (self->priv->should_overwrite)
{
g_file_replace_async (target_file,
NULL, FALSE,
G_FILE_CREATE_NONE,
G_PRIORITY_DEFAULT,
NULL,
save_file_create_ready_cb, self);
}
else
{
g_file_create_async (target_file,
G_FILE_CREATE_NONE,
G_PRIORITY_DEFAULT,
NULL,
save_file_create_ready_cb, self);
}
g_object_unref (target_file);
} | false | false | false | false | false | 0 |
pop_arguments (tree method_type)
{
function_args_iterator fnai;
tree type;
vec<tree, va_gc> *args = NULL;
int arity;
FOREACH_FUNCTION_ARGS (method_type, type, fnai)
{
/* XXX: leaky abstraction. */
if (type == void_type_node)
break;
vec_safe_push (args, type);
}
arity = vec_safe_length (args);
while (arity--)
{
tree arg = pop_value ((*args)[arity]);
/* We simply cast each argument to its proper type. This is
needed since we lose type information coming out of the
verifier. We also have to do this when we pop an integer
type that must be promoted for the function call. */
if (TREE_CODE (type) == POINTER_TYPE)
arg = build1 (NOP_EXPR, type, arg);
else if (targetm.calls.promote_prototypes (type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
&& INTEGRAL_TYPE_P (type))
arg = convert (integer_type_node, arg);
(*args)[arity] = arg;
}
return args;
} | false | false | false | false | false | 0 |
do_message_scan() {
DB_MSG_FROM_HOST mfh;
char buf[256];
bool found=false;
int retval;
sprintf(buf, "where handled=0");
while (1) {
retval = mfh.enumerate(buf);
if (retval) {
if (retval != ERR_DB_NOT_FOUND) {
log_messages.printf(MSG_DEBUG,
"DB connection lost, exiting\n"
);
exit(0);
}
break;
}
retval = handle_message(mfh);
if (!retval) {
mfh.handled = true;
mfh.update();
}
found = true;
}
return found;
} | false | false | false | false | false | 0 |
nm_supplicant_interface_get_ifname (NMSupplicantInterface *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL);
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev;
} | false | false | false | false | false | 0 |
event(uint8_t buf[], uint16_t message_id, const char *event_name,
const char *data, int ttl, EventType::Enum event_type)
{
uint8_t *p = buf;
*p++ = 0x50; // non-confirmable, no token
*p++ = 0x02; // code 0.02 POST request
*p++ = message_id >> 8;
*p++ = message_id & 0xff;
*p++ = 0xb1; // one-byte Uri-Path option
*p++ = event_type;
size_t name_data_len = strnlen(event_name, 63);
p += event_name_uri_path(p, event_name, name_data_len);
if (60 != ttl)
{
*p++ = 0x33;
*p++ = (ttl >> 16) & 0xff;
*p++ = (ttl >> 8) & 0xff;
*p++ = ttl & 0xff;
}
if (NULL != data)
{
name_data_len = strnlen(data, 63);
*p++ = 0xff;
memcpy(p, data, name_data_len);
p += name_data_len;
}
return p - buf;
} | false | false | false | false | false | 0 |
operator=(const Theorem& th) {
// Handle self-assignment
if(this == &th) return *this;
if(d_thm == th.d_thm) return *this;
long tmp = th.d_thm;
// Increase the refcount on th
if (tmp & 0x1) {
TheoremValue* tv = (TheoremValue*) (tmp & (~(0x1)));
DebugAssert(tv->d_refcount > 0,
"Theorem::operator=: invariant violated");
++(tv->d_refcount);
}
else if (tmp != 0) {
th.exprValue()->incRefcount();
}
// Decrease the refcount on this
if (d_thm & 0x1) {
TheoremValue* tv = thm();
DebugAssert(tv->d_refcount > 0,
"Theorem::operator=: invariant violated");
if(--(tv->d_refcount) == 0) {
MemoryManager* mm = tv->getMM();
delete tv;
mm->deleteData(tv);
}
}
else if (d_thm != 0) {
exprValue()->decRefcount();
}
d_thm = tmp;
return *this;
} | false | false | false | false | false | 0 |
wi_ip_version(wi_string_t *ip) {
struct sockaddr_in sa_in;
struct sockaddr_in6 sa_in6;
if(wi_string_contains_string(ip, WI_STR("."), 0)) {
if(inet_pton(AF_INET, wi_string_cstring(ip), &sa_in.sin_addr) > 0)
return WI_IP_IPV4;
}
else if(wi_string_contains_string(ip, WI_STR(":"), 0)) {
if(inet_pton(AF_INET6, wi_string_cstring(ip), &sa_in6.sin6_addr) > 0)
return WI_IP_IPV6;
}
return WI_IP_NULL;
} | false | false | false | false | false | 0 |
runOnBasicBlock(BasicBlock &BB) {
if (skipOptnoneFunction(BB))
return false;
AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
IRBuilder<true, TargetFolder> TheBuilder(
BB.getContext(), TargetFolder(BB.getModule()->getDataLayout()));
Builder = &TheBuilder;
DenseMap<const Value *, SmallVector<LoadPOPPair, 8>> LoadMap;
AliasSetTracker AST(*AA);
bool Combined = false;
unsigned Index = 0;
for (auto &I : BB) {
if (I.mayThrow() || (I.mayWriteToMemory() && AST.containsUnknown(&I))) {
if (combineLoads(LoadMap))
Combined = true;
LoadMap.clear();
AST.clear();
continue;
}
LoadInst *LI = dyn_cast<LoadInst>(&I);
if (!LI)
continue;
++NumLoadsAnalyzed;
if (!LI->isSimple() || !LI->getType()->isIntegerTy())
continue;
auto POP = getPointerOffsetPair(*LI);
if (!POP.Pointer)
continue;
LoadMap[POP.Pointer].push_back(LoadPOPPair(LI, POP, Index++));
AST.add(LI);
}
if (combineLoads(LoadMap))
Combined = true;
return Combined;
} | false | false | false | false | false | 0 |
nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl)
{
struct nlm_rqst *req;
int status;
dprintk("lockd: blocking lock attempt was interrupted by a signal.\n"
" Attempting to cancel lock.\n");
req = nlm_alloc_call(host);
if (!req)
return -ENOMEM;
req->a_flags = RPC_TASK_ASYNC;
nlmclnt_setlockargs(req, fl);
req->a_args.block = block;
atomic_inc(&req->a_count);
status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
NLMPROC_CANCEL, &nlmclnt_cancel_ops);
if (status == 0 && req->a_res.status == nlm_lck_denied)
status = -ENOLCK;
nlmclnt_release_call(req);
return status;
} | false | false | false | false | false | 0 |
isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const {
// FIXME: Return false for x87 stack register classes for now. We can't
// allow any loads of these registers before FpGet_ST0_80.
return !(RC == &X86::CCRRegClass || RC == &X86::RFP32RegClass ||
RC == &X86::RFP64RegClass || RC == &X86::RFP80RegClass);
} | false | false | false | false | false | 0 |
disk_flush_events(struct gendisk *disk, unsigned int mask)
{
struct disk_events *ev = disk->ev;
if (!ev)
return;
spin_lock_irq(&ev->lock);
ev->clearing |= mask;
if (!ev->block)
mod_delayed_work(system_freezable_power_efficient_wq,
&ev->dwork, 0);
spin_unlock_irq(&ev->lock);
} | false | false | false | false | false | 0 |
brasero_metadata_stop_pipeline (GstElement *pipeline)
{
GstState state;
GstStateChangeReturn change;
change = gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_NULL);
change = gst_element_get_state (pipeline,
&state,
NULL,
GST_MSECOND);
/* better wait for the state change to be completed */
while (change == GST_STATE_CHANGE_ASYNC && state != GST_STATE_NULL) {
GstState pending;
change = gst_element_get_state (pipeline,
&state,
&pending,
GST_MSECOND);
BRASERO_UTILS_LOG ("Get state (current = %i pending = %i) returned %i",
state, pending, change);
}
if (change == GST_STATE_CHANGE_FAILURE)
g_warning ("State change failure");
} | false | false | false | false | false | 0 |
DateCalc_Blank(charptr *target, Z_int count)
{
while (count-- > 0) *(*target)++ = ' ';
*(*target) = '\0';
} | false | false | false | false | false | 0 |
lgetxattrs_stub (XDR *xdr_in)
{
guestfs_int_xattr_list *r;
struct guestfs_lgetxattrs_args args;
const char *path;
/* The caller should have checked before calling this. */
if (! optgroup_linuxxattrs_available ()) {
reply_with_error_errno (ENOTSUP,
"feature '%s' is not available in this\n"
"build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for\n"
"how to check for the availability of features.",
"linuxxattrs");
goto done_no_free;
}
if (optargs_bitmask != 0) {
reply_with_error ("header optargs_bitmask field must be passed as 0 for calls that don't take optional arguments");
goto done_no_free;
}
memset (&args, 0, sizeof args);
if (!xdr_guestfs_lgetxattrs_args (xdr_in, &args)) {
reply_with_error ("daemon failed to decode procedure arguments");
goto done;
}
path = args.path;
ABS_PATH (path, , goto done);
NEED_ROOT (, goto done);
r = do_lgetxattrs (path);
if (r == NULL)
/* do_lgetxattrs has already called reply_with_error */
goto done;
struct guestfs_lgetxattrs_ret ret;
ret.xattrs = *r;
free (r);
reply ((xdrproc_t) xdr_guestfs_lgetxattrs_ret, (char *) &ret);
xdr_free ((xdrproc_t) xdr_guestfs_lgetxattrs_ret, (char *) &ret);
done:
xdr_free ((xdrproc_t) xdr_guestfs_lgetxattrs_args, (char *) &args);
done_no_free:
return;
} | false | false | false | false | false | 0 |
putQChemGuessOptionsInfoInTextEditor()
{
if(GTK_TOGGLE_BUTTON (buttonMixed)->active)
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " scf_guess_mix 5\n",-1);
} | false | false | false | false | false | 0 |
prot_autoc_write_82599(struct ixgbe_hw *hw, u32 autoc, bool locked)
{
s32 ret_val = 0;
/* Blocked by MNG FW so bail */
if (ixgbe_check_reset_blocked(hw))
goto out;
/* We only need to get the lock if:
* - We didn't do it already (in the read part of a read-modify-write)
* - LESM is enabled.
*/
if (!locked && ixgbe_verify_lesm_fw_enabled_82599(hw)) {
ret_val = hw->mac.ops.acquire_swfw_sync(hw,
IXGBE_GSSR_MAC_CSR_SM);
if (ret_val)
return IXGBE_ERR_SWFW_SYNC;
locked = true;
}
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
ret_val = ixgbe_reset_pipeline_82599(hw);
out:
/* Free the SW/FW semaphore as we either grabbed it here or
* already had it when this function was called.
*/
if (locked)
hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
return ret_val;
} | false | false | false | false | false | 0 |
isl_upoly_cst_reduce(__isl_keep struct isl_upoly_cst *cst)
{
isl_int gcd;
isl_int_init(gcd);
isl_int_gcd(gcd, cst->n, cst->d);
if (!isl_int_is_zero(gcd) && !isl_int_is_one(gcd)) {
isl_int_divexact(cst->n, cst->n, gcd);
isl_int_divexact(cst->d, cst->d, gcd);
}
isl_int_clear(gcd);
} | false | false | false | false | false | 0 |
Check(bool check_meta) {
// simply check that the file can be resolved
DataStatus r = Resolve(true);
if (r) return r;
return DataStatus(DataStatus::CheckError, r.GetErrno(), r.GetDesc());
} | false | false | false | false | false | 0 |
TCSP_LoadManuMaintPub_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
TCPA_NONCE antiReplay, /* in */
UINT32 PubKeySize, /* in */
BYTE * PubKey, /* in */
TCPA_DIGEST * checksum) /* out */
{
TSS_RESULT result;
UINT32 paramSize;
UINT64 offset = 0;
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
LogDebug("Entering Load Manu Maint Pub");
if ((result = tpm_rqu_build(TPM_ORD_LoadManuMaintPub, &offset, txBlob, TPM_NONCE_SIZE,
antiReplay.nonce, PubKeySize, PubKey, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
return result;
result = UnloadBlob_Header(txBlob, ¶mSize);
if (!result) {
result = tpm_rsp_parse(TPM_ORD_LoadManuMaintPub, txBlob, paramSize, NULL,
checksum->digest);
}
LogResult("Load Manu Maint Pub", result);
return result;
} | false | false | false | false | false | 0 |
camel_internet_address_find_address (CamelInternetAddress *addr,
const gchar *address,
const gchar **namep)
{
struct _address *a;
gint i, len;
g_assert (CAMEL_IS_INTERNET_ADDRESS (addr));
len = ((CamelAddress *) addr)->addresses->len;
for (i = 0; i < len; i++) {
a = g_ptr_array_index (((CamelAddress *) addr)->addresses, i);
if (!strcmp (a->address, address)) {
if (namep)
*namep = a->name;
return i;
}
}
return -1;
} | false | false | false | false | false | 0 |
FetchStorage(const struct sess *sp, ssize_t sz)
{
ssize_t l;
struct storage *st;
st = VTAILQ_LAST(&sp->obj->store, storagehead);
if (st != NULL && st->len < st->space)
return (st);
l = fetchfrag;
if (l == 0)
l = sz;
if (l == 0)
l = params->fetch_chunksize * 1024LL;
st = STV_alloc(sp, l);
if (st == NULL) {
errno = ENOMEM;
return (NULL);
}
AZ(st->len);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
return (st);
} | false | false | false | false | false | 0 |
wait_not_in_use() /* leaves fides_mutex set */
{
lock();
while (m_in_use) {
unlock();
bmicrosleep(0, 200); /* wait */
lock();
}
} | false | false | false | false | false | 0 |
format_one(std::ostream& os, const option_description& opt,
unsigned first_column_width, unsigned line_length)
{
stringstream ss;
ss << " " << opt.format_name() << ' ' << opt.format_parameter();
// Don't use ss.rdbuf() since g++ 2.96 is buggy on it.
os << ss.str();
if (!opt.description().empty())
{
if (ss.str().size() >= first_column_width)
{
os.put('\n'); // first column is too long, lets put description in new line
for (unsigned pad = first_column_width; pad > 0; --pad)
{
os.put(' ');
}
} else {
for(unsigned pad = first_column_width - static_cast<unsigned>(ss.str().size()); pad > 0; --pad)
{
os.put(' ');
}
}
format_description(os, opt.description(),
first_column_width, line_length);
}
} | false | false | false | false | false | 0 |
sil164_get_hw_state(struct intel_dvo_device *dvo)
{
int ret;
unsigned char ch;
ret = sil164_readb(dvo, SIL164_REG8, &ch);
if (ret == false)
return false;
if (ch & SIL164_8_PD)
return true;
else
return false;
} | false | false | false | false | false | 0 |
blame_renderer_query_tooltip_cb (GtkSourceGutterRenderer *renderer,
GtkTextIter *iter,
GdkRectangle *area,
gint x,
gint y,
GtkTooltip *tooltip,
GitgRevisionFilesView *tree)
{
GtkTextTag *tag;
GitgRevision *rev;
const gchar *author;
const gchar *committer;
const gchar *subject;
gchar *text;
gchar *sha1;
gchar *author_date;
gchar *committer_date;
tag = get_blame_tag_from_iter (tree, iter);
if (tag == NULL)
return FALSE;
rev = g_object_get_data (G_OBJECT (tag), BLAME_DATA);
if (rev == NULL)
return FALSE;
sha1 = gitg_revision_get_sha1 (rev);
author_date = gitg_revision_get_author_date_for_display (rev);
committer_date = gitg_revision_get_committer_date_for_display (rev);
author = _("Author");
committer = _("Committer");
subject = _("Subject");
text = g_markup_printf_escaped ("<b>SHA:</b> %s\n"
"<b>%s:</b> %s <%s> (%s)\n"
"<b>%s:</b> %s <%s> (%s)\n"
"<b>%s:</b> <i>%s</i>",
sha1,
author, gitg_revision_get_author (rev),
gitg_revision_get_author_email (rev),
author_date,
committer, gitg_revision_get_committer (rev),
gitg_revision_get_committer_email (rev),
committer_date,
subject, gitg_revision_get_subject (rev));
g_free (sha1);
g_free (author_date);
g_free (committer_date);
gtk_tooltip_set_markup (tooltip, text);
g_free (text);
return TRUE;
} | false | false | false | false | false | 0 |
ShowInstanceMarker(DisplayOrErase,Layer,Pointer)
int Layer;
int DisplayOrErase;
struct o *Pointer;
{
struct t *TGen;
char Type;
int DX,DY,X,Y;
if(Not Parameters.kpShowInstanceMarkers)
return;
/*Mark reference point of symbol call */
X = Y = 0;
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&DX,&DY);
if(TGen == NULL)
break;
elif(Type == CDTRANSLATE){
X = DX;
Y = DY;
}
}
ShowMarker(DisplayOrErase,Layer,X,Y,200);
} | false | false | false | false | false | 0 |
rqs_match_host_scope(lList *scope, const char *name, lList *master_hgroup_list, bool is_xscope)
{
lListElem *ep;
DENTER(TOP_LAYER, "rqs_match_host_scope");
if (lGetElemStr(scope, ST_name, "*")) {
DRETURN(true);
}
if (sge_is_pattern(name) || is_hgroup_name(name)) {
DRETURN(rqs_match_user_host_scope(scope, FILTER_HOSTS, name, NULL, master_hgroup_list, NULL, is_xscope));
}
/* at this stage we know 'name' is a simple hostname */
for_each(ep, scope) {
if (!qref_list_host_rejected(lGetString(ep, ST_name), name, master_hgroup_list)) {
DRETURN(true);
}
}
DRETURN(false);
} | false | false | false | false | false | 0 |
Swig_register_module(const char *n, ModuleFactory f) {
Module *m = new Module(n, f);
m->next = modules;
modules = m;
} | false | false | false | false | false | 0 |
_e2p_pack_yes (E2_PackDlgRunTime *rt)
{
static gchar *cmd_str [MAXTYPES] =
{ //these command strings are in same order as enum
//NOTE that %%f is converted to %f when the command is constructed with g_strdup_printf ()
">tar cvf - %%f | gzip - > \"%s\"", //run in separate shell
">tar cvf - %%f | bzip2 - > \"%s\"", //ditto
"tar cvf \"%s\" %%f",
"zip -r \"%s\" %%f",
"7za a -t7z \"%s\" %%f",
"rar a -r -ol \"%s\" %%f",
"arj a -a1 -r \"%s\" %%f",
"zoo ahP \"%s\" %%f"
};
/*
compress ANSI files: 7za a -tzip archive.zip file1 file2 ... fileN
compress ANSI dir: 7za a -tzip archive.zip dirnametocompress\
compress UNICODE files: 7za a -t7z archive.7z file1 file2 ... fileN
compress UNICODE dir: 7za a -t7z archive.7z dirnametocompress\
decompress ANSI: 7za x archive.zip -odirname -aoa
decompress UNICODE: 7za x archive.7z -odirname -aoa
*/
pkg_type = gtk_combo_box_get_active (GTK_COMBO_BOX (rt->pkgtype_combo));
if (pkg_type != -1)
{
gchar *full_name;
const gchar *chosen_name = gtk_entry_get_text (GTK_ENTRY (rt->filename_entry));
gboolean flag = (*chosen_name != '\0');
if (flag)
{
full_name = g_strconcat (chosen_name, ext_str [pkg_type], NULL);
if (e2_option_bool_get ("confirm-overwrite"))
{
#ifdef E2_VFSTMP
//FIXME dir when not mounted local
#else
gchar *utf = g_strconcat (rt->curr_dir, full_name, NULL); //separator comes with dir
#endif
gchar *dlocal = F_FILENAME_TO_LOCALE (utf);
#ifdef E2_VFS
VPATH ddata = { dlocal, NULL }; //running a command is only local
if (e2_fs_access2 (&ddata E2_ERR_NONE()) == 0)
#else
if (e2_fs_access2 (dlocal E2_ERR_NONE()) == 0)
#endif
{ //same-named item exists already
//FIXME some apps allow addition to existing archive
DialogButtons result = e2_dialog_ow_check (NULL, dlocal, NONE);
if (result != OK)
{
flag = FALSE; //signal that we will not proceed
g_free (full_name);
}
}
g_free (utf);
F_FREE (dlocal);
}
}
if (flag)
{
gchar *command = g_strdup_printf (cmd_str [pkg_type], full_name);
// e2_filelist_disable_refresh (); //prevent changes to selected item data
// gint res =
#ifdef E2_COMMANDQ
e2_command_run (command, E2_COMMAND_RANGE_DEFAULT, FALSE);
#else
e2_command_run (command, E2_COMMAND_RANGE_DEFAULT);
#endif
// e2_filelist_enable_refresh (); //probably nothing reported yet, to trigger a refresh
// flag = (res == 0);
g_free (command);
g_free (full_name);
}
}
else
pkg_type = TAR_GZ;
} | false | false | false | false | false | 0 |
AllocateNearest_ (size_t *pixelsNP, GUIS *guiSP)
{
static size_t elementsN;
static size_t struct_size;
static size_t mem_size;
static NearestAtomS *nearest_atomSP;
/* Prepare the parameters which define the size of memory chunk: */
elementsN = (size_t) guiSP->main_win_free_area_width *
(size_t) guiSP->main_win_free_area_height;
struct_size = sizeof (NearestAtomS);
/* Allocate memory: */
nearest_atomSP = (NearestAtomS *) calloc (elementsN, struct_size);
/* On failure: */
if (nearest_atomSP == NULL)
{
ErrorMessage_ ("garlic", "AllocateNearest_", "",
"Failed to allocate memory for NearestAtomS array!\n",
"", "", "");
mem_size = elementsN * struct_size;
fprintf (stderr, "A total of %d bytes required.\n", mem_size);
*pixelsNP = 0;
return NULL;
}
/* On success, update the number of pixels: */
*pixelsNP = elementsN;
return nearest_atomSP;
} | false | false | false | false | false | 0 |
PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Chain code 2D: " << GetChainCodeAsString() << std::endl;
} | false | false | false | false | false | 0 |
connect_pppoatm(void)
{
int fd;
struct atm_qos qos;
system ("/sbin/modprobe -q pppoatm");
if (!device_got_set)
no_device_given_pppoatm();
fd = socket(AF_ATMPVC, SOCK_DGRAM, 0);
if (fd < 0)
fatal("failed to create socket: %m");
memset(&qos, 0, sizeof qos);
qos.txtp.traffic_class = qos.rxtp.traffic_class = ATM_UBR;
/* TODO: support simplified QoS setting */
if (qosstr != NULL)
if (text2qos(qosstr, &qos, 0))
fatal("Can't parse QoS: \"%s\"");
qos.txtp.max_sdu = lcp_allowoptions[0].mru + pppoatm_overhead();
qos.rxtp.max_sdu = lcp_wantoptions[0].mru + pppoatm_overhead();
qos.aal = ATM_AAL5;
if (setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0)
fatal("setsockopt(SO_ATMQOS): %m");
/* TODO: accept on SVCs... */
if (connect(fd, (struct sockaddr *) &pvcaddr,
sizeof(struct sockaddr_atmpvc)))
fatal("connect(%s): %m", devnam);
pppoatm_max_mtu = lcp_allowoptions[0].mru;
pppoatm_max_mru = lcp_wantoptions[0].mru;
set_line_discipline_pppoatm(fd);
strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));
pppoa_fd = fd;
return fd;
} | false | false | false | false | false | 0 |
generateSelect2 (Tree sig, Tree sel, Tree s1, Tree s2, int priority)
{
string var = getFreshID("q");
string expsel = CS(sel, 0);
string exps1 = CS(s1, 0);
string exps2 = CS(s2, 0);
string ltqSelDef;
ltqSelDef += subst("$0(t) = \n", var);
ltqSelDef += "\\left\\{\\begin{array}{ll}\n";
ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 0\\\\\n", exps1, expsel);
ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 1\n", exps2, expsel);
ltqSelDef += "\\end{array}\\right.";
fLateq->addSelectSigFormula(ltqSelDef);
gDocNoticeFlagMap["selectionsigs"] = true;
//return generateCacheCode(sig, subst("$0(t)", var));
setVectorNameProperty(sig, var);
return subst("$0(t)", var);
} | false | false | false | false | false | 0 |
doFinalization(Module &M) {
const DataLayout &DL = getDataLayout();
bool isPPC64 = DL.getPointerSizeInBits() == 64;
PPCTargetStreamer &TS =
static_cast<PPCTargetStreamer &>(*OutStreamer->getTargetStreamer());
if (!TOC.empty()) {
MCSectionELF *Section;
if (isPPC64)
Section = OutStreamer->getContext().getELFSection(
".toc", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
else
Section = OutStreamer->getContext().getELFSection(
".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
OutStreamer->SwitchSection(Section);
for (MapVector<MCSymbol*, MCSymbol*>::iterator I = TOC.begin(),
E = TOC.end(); I != E; ++I) {
OutStreamer->EmitLabel(I->second);
MCSymbol *S = I->first;
if (isPPC64)
TS.emitTCEntry(*S);
else
OutStreamer->EmitSymbolValue(S, 4);
}
}
return AsmPrinter::doFinalization(M);
} | false | false | false | false | false | 0 |
eval_tskassign_rhsexpr(register struct xstk_t *xsp,
register int32 lhsreal, register int32 lhswid, register int32 rhsreal,
register int32 rhssign)
{
if (lhsreal)
{
/* think passing packed bit does not work on all compilers ? */
if (!rhsreal) __cnv_stk_fromreg_toreal(xsp, rhssign);
}
else
{
/* handle rhs preparation of reals - then assign is just copy for reals */
if (rhsreal) __cnv_stk_fromreal_toreg32(xsp);
if (xsp->xslen > lhswid) __narrow_sizchg(xsp, lhswid);
else if (xsp->xslen < lhswid)
{
if (rhssign) __sgn_xtnd_widen(xsp, lhswid);
else __sizchg_widen(xsp, lhswid);
}
}
} | false | false | false | false | false | 0 |
lookChar() {
if (src.abort) return EOF;
return *current;
} | false | false | false | false | false | 0 |
rideSelected()
{
bool wasActive = active;
active = amVisible();
if (!wasActive && active)
replot();
} | false | false | false | false | false | 0 |
generateKey(SECKEYPublicKey** publicKey, char* tokenName)
{
SECKEYPrivateKey* privateKey = NULL;
PK11RSAGenParams params;
unsigned char *rand_buffer = NULL;
PK11SlotInfo *slot;
/* Add the secure info to the context before we create the key. */
/* Do it here so that we can zero it immediately and keep it in */
/* memory for as little time as possible. */
/*get_random_user_input();*/
rand_buffer = ( unsigned char *) PORT_Alloc(TOTAL_BITS*sizeof(char));
/* This function will try to seed it self with good random value if possible */
PK11_GenerateRandom(rand_buffer, TOTAL_BITS);
/* This function assume you going to pass in a random number generateor */
/* will use this method if HCL can't provide a good random number generator */
PK11_RandomUpdate(rand_buffer, TOTAL_BITS);
/*slot = PK11_GetInternalKeySlot();*/
/*DebugBreak();*/
slot = PK11_FindSlotByName(tokenName);
if (slot == NULL) {
goto loser;
}
/*private key can't be generated until you call PK11_Authenticate. If password is set to null, or not
set at all then it doen't matter if you call PK11_Authenticate or not*/
PK11_Authenticate(slot, PR_FALSE, 0);
/* generate key pair */
{
char *sKeySize = get_cgi_var("keysize", NULL, NULL);
int keySize = 0;
if (sKeySize) {
keySize = atoi(sKeySize);
}
if (keySize > MAX_KEY_BITS) {
params.keySizeInBits = MAX_KEY_BITS;
} else if (keySize <= 0) {
params.keySizeInBits = DEFAULT_KEY_BITS;
} else {
params.keySizeInBits = keySize;
}
}
params.pe = DEFAULT_PUBLIC_EXPONENT;
privateKey = PK11_GenerateKeyPair(slot, CKM_RSA_PKCS_KEY_PAIR_GEN, ¶ms, publicKey, PR_TRUE, PR_TRUE, 0);
/*PK11_ImportPublicKey(slot, publicKey);*/
loser:
if (privateKey==NULL) {
PR_snprintf(line, sizeof(line), "%d:%s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_EN));
rpt_err(GENERAL_FAILURE,
getResourceString(DBT_INTERNAL_ERROR),
getResourceString(DBT_INVALID_KEY_PAIR),
line);
}
return privateKey;
} | false | false | false | false | false | 0 |