int glsl_type::record_key_compare(const void *a, const void *b) { const glsl_type *const key1 = (glsl_type *) a; const glsl_type *const key2 = (glsl_type *) b; /* Return zero is the types match (there is zero difference) or non-zero * otherwise. */ if (safe_strcmp(key1->name, key2->name) != 0) return 1; if (key1->length != key2->length) return 1; for (unsigned i = 0; i < key1->length; i++) { if (key1->fields.structure[i].type != key2->fields.structure[i].type) return 1; if (safe_strcmp(key1->fields.structure[i].name, key2->fields.structure[i].name) != 0) return 1; } return 0; }
int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b) { int ret; if (!a && !b) return 0; if (!a) return -1; if (!b) return 1; ret = safe_strcmp (a->name, b->name); if (ret) return ret; return safe_strcmp (a->desc, b->desc); }
/* ** Print an error message and then quit. */ static void fatalError(const char *zFormat, ...){ va_list ap; char *zMsg; char zPrefix[30]; va_start(ap, zFormat); zMsg = sqlite3_vmprintf(zFormat, ap); va_end(ap); sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:FATAL: ", g.zName); if( g.pLog ){ printWithPrefix(g.pLog, zPrefix, zMsg); fflush(g.pLog); maybeClose(g.pLog); } if( g.pErrLog && safe_strcmp(g.zErrLog,g.zLog) ){ printWithPrefix(g.pErrLog, zPrefix, zMsg); fflush(g.pErrLog); maybeClose(g.pErrLog); } sqlite3_free(zMsg); if( g.db ){ int nTry = 0; g.iTimeout = 0; while( trySql("UPDATE client SET wantHalt=1;")==SQLITE_BUSY && (nTry++)<100 ){ sqlite3_sleep(10); } } sqlite3_close(g.db); exit(1); }
/* * Mount the volume identified by drive_guid to mountpoint drive_name */ BOOL MountVolume(char* drive_name, char *drive_guid) { char mounted_guid[52]; // You need at least 51 characters on XP if (!SetVolumeMountPointA(drive_name, drive_guid)) { // If the OS was faster than us at remounting the drive, this operation can fail // with ERROR_DIR_NOT_EMPTY. If that's the case, just check that mountpoints match if (GetLastError() == ERROR_DIR_NOT_EMPTY) { if (!GetVolumeNameForVolumeMountPointA(drive_name, mounted_guid, sizeof(mounted_guid))) { uprintf("%s already mounted, but volume GUID could not be checked: %s\n", drive_name, WindowsErrorString()); return FALSE; } if (safe_strcmp(drive_guid, mounted_guid) != 0) { uprintf("%s already mounted, but volume GUID doesn't match:\r\n expected %s, got %s\n", drive_name, drive_guid, mounted_guid); return FALSE; } uprintf("%s was already mounted as %s\n", drive_guid, drive_name); } else { return FALSE; } } return TRUE; }
int getIPv6Addr(char *intf, char *ipv6addr) { L3Addr_t ips[10] = {0}; int cnt = 0; int i = 0; char buf[100] = {0}; kinfo("Enter"); if(!safe_strcmp(intf, "br0")) cnt = getL3LocalList(ips, 10, NULL); kinfo("ipaddr (totally %d)", cnt); for(i = 0; i < cnt; i++) { kinfo("%s, type(%d)", ips[i].ipAddrStr, ips[i].type); changeString(ips[i].ipAddrStr); sprintf(buf, "%d|%s||", ips[i].type, ips[i].ipAddrStr); strcat(ipv6addr, buf); } return 0; }
/* * Open a localization file and store its file name, with special case * when dealing with the embedded loc file. */ FILE* open_loc_file(const char* filename) { FILE* fd = NULL; wchar_t *wfilename = NULL; const char* tmp_ext = ".tmp"; if (filename == NULL) return NULL; if (loc_filename != embedded_loc_filename) { safe_free(loc_filename); } if (safe_strcmp(tmp_ext, &filename[safe_strlen(filename)-4]) == 0) { loc_filename = embedded_loc_filename; } else { loc_filename = safe_strdup(filename); } wfilename = utf8_to_wchar(filename); if (wfilename == NULL) { uprintf(conversion_error, filename); goto out; } fd = _wfopen(wfilename, L"rb"); if (fd == NULL) { uprintf("localization: could not open '%s'\n", filename); } out: safe_free(wfilename); return fd; }
static void test_load_file(const char *filename) { QofSession *session; QofBook *book; Account *root; gboolean ignore_lock; gchar *logdomain = "GConf"; guint loglevel = G_LOG_LEVEL_WARNING; TestErrorStruct check = { loglevel, logdomain, NULL }; g_log_set_handler (logdomain, loglevel, (GLogFunc)test_checked_handler, &check); session = qof_session_new(); remove_locks(filename); ignore_lock = (safe_strcmp(g_getenv("SRCDIR"), ".") != 0); qof_session_begin(session, filename, ignore_lock, FALSE, TRUE); qof_session_load(session, NULL); book = qof_session_get_book (session); root = gnc_book_get_root_account(book); do_test (gnc_account_get_book (root) == book, "book and root account don't match"); do_test_args(qof_session_get_error(session) == ERR_BACKEND_NO_ERR, "session load xml2", __FILE__, __LINE__, "qof error=%d for file [%s]", qof_session_get_error(session), filename); /* Uncomment the line below to generate corrected files */ qof_session_save( session, NULL ); qof_session_end(session); }
static void check_cb (QofInstance *ent, gpointer data) { QofInstance *parent, *child; QofCollection *coll; struct tally *c; const QofParam *param; mygrand *testg; myparent *testp; mychild *testc; c = (struct tally*)data; /* check the same number and type of entities exist in the copied book */ testg = (mygrand*)ent; /* we always have a grandparent */ do_test((testg != NULL), "grandparent not found"); c->total++; param = qof_class_get_parameter(GRAND_MODULE_NAME, OBJ_LIST); coll = (QofCollection*)param->param_getfcn(ent, param); c->collect = qof_collection_count(coll); if (c->book) { qof_book_set_references(c->book); } param = qof_class_get_parameter(GRAND_MODULE_NAME, OBJ_RELATIVE); parent = QOF_INSTANCE(param->param_getfcn(ent, param)); testp = grand_getChild((mygrand*)ent); /* not all grandparents have family so just keep count. */ if (!parent) { c->nulls++; return; } do_test((0 == safe_strcmp(parent_getName(testp), parent_getName((myparent*)parent))), "parent copy test"); param = qof_class_get_parameter(PARENT_MODULE_NAME, OBJ_RELATIVE); child = param->param_getfcn(parent, param); testc = parent_getChild((myparent*)parent); if (!child) { c->nulls++; return; } do_test((0 == safe_strcmp(child_getName(testc), child_getName((mychild*)child))), "child copy test"); }
static xmlNodePtr find_appropriate_node(xmlNodePtr node, Split *spl) { xmlNodePtr mark; for (mark = node->xmlChildrenNode; mark; mark = mark->next) { gboolean account_guid_good = FALSE; gboolean amount_good = FALSE; xmlNodePtr mark2; for (mark2 = mark->xmlChildrenNode; mark2; mark2 = mark2->next) { if (safe_strcmp((char*)mark2->name, "split:value") == 0) { gnc_numeric *num = dom_tree_to_gnc_numeric(mark2); if (gnc_numeric_equal(*num, xaccSplitGetValue(spl))) { amount_good = TRUE; } g_free(num); } else if (safe_strcmp((char*)mark2->name, "split:account") == 0) { GncGUID *accid = dom_tree_to_guid(mark2); Account *account = xaccSplitGetAccount (spl); if (guid_equal(accid, xaccAccountGetGUID(account))) { account_guid_good = TRUE; } g_free(accid); } if (account_guid_good && amount_good) { return mark; } } } return NULL; }
/********************************************************************\ * gnc_query_list_set_query_sort * * sets the sorting order of entries in the list * * * * Args: list - list to change the sort order for * * new_column - is this a new column (so should we set the * * query sort order or just set the 'increasing' * * Returns: nothing * \********************************************************************/ static void gnc_query_list_set_query_sort (GNCQueryList *list, gboolean new_column) { gboolean sort_order = list->increasing; GList *node; GNCSearchParam *param; /* Find the column parameter definition */ node = g_list_nth(list->column_params, list->sort_column); param = node->data; /* If we're asked to invert numerics, and if this is a numeric or * debred column, then invert the sort order. */ if (list->numeric_inv_sort) { const char *type = gnc_search_param_get_param_type (param); if (!safe_strcmp(type, QOF_TYPE_NUMERIC) || !safe_strcmp(type, QOF_TYPE_DEBCRED)) sort_order = !sort_order; } /* Set the sort order for the engine, if the key changed */ if (new_column) { GSList *p1, *p2; p1 = gnc_search_param_get_param_path(param); p2 = g_slist_prepend(NULL, QUERY_DEFAULT_SORT); qof_query_set_sort_order (list->query, p1, p2, NULL); } qof_query_set_sort_increasing (list->query, sort_order, sort_order, sort_order); /* * Recompute the list. Is this really necessary? Why not just sort * the rows already in the clist? Answer: it would be an n-squared * algorithm to get the clist to match the resulting list. */ gnc_query_list_refresh(list); }
static void set_value_combo_cell(BasicCell *cell, const char *new_value) { if (!cell || !new_value) return; if (safe_strcmp (new_value, gnc_basic_cell_get_value (cell)) == 0) return; gnc_combo_cell_set_value ((ComboCell *) cell, new_value); gnc_basic_cell_set_changed (cell, TRUE); }
WeekendAdjust recurrenceWeekendAdjustFromString(const gchar *str) { int i; for (i = 0; i < NUM_WEEKEND_ADJS; i++) if (safe_strcmp(weekend_adj_strings[i], str) == 0) return i; return -1; }
static gboolean g_vfs_icon_equal (GIcon *icon1, GIcon *icon2) { GVfsIcon *vfs1 = G_VFS_ICON (icon1); GVfsIcon *vfs2 = G_VFS_ICON (icon2); return g_mount_spec_equal (vfs1->mount_spec, vfs2->mount_spec) && (safe_strcmp (vfs1->icon_id, vfs2->icon_id) == 0); }
static int seatcmp(GGZSeat seat1, GGZSeat seat2) { if (seat1.num == seat2.num && seat1.type == seat2.type && seat1.fd == seat2.fd && safe_strcmp(seat1.name, seat2.name) == 0) return 0; else return -1; }
ir_expression_operation ir_expression::get_operator(const char *str) { const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); for (int op = 0; op < operator_count; op++) { if (safe_strcmp(str, operator_strs[op]) == 0) return (ir_expression_operation) op; } return (ir_expression_operation) -1; }
PeriodType recurrencePeriodTypeFromString(const gchar *str) { int i; for (i = 0; i < NUM_PERIOD_TYPES; i++) if (safe_strcmp(period_type_strings[i], str) == 0) return i; return -1; }
static void grand_setDescend(mygrand *g, QofCollection *coll) { g_return_if_fail(g || coll); if (0 != safe_strcmp(qof_collection_get_type(coll), CHILD_MODULE_NAME)) { return; } qof_collection_foreach(coll, descend_cb, g); }
static int ms_get_kbdrv(const char* kb) { unsigned int i, j; for (i=0; i<ARRAYSIZE(ms_kb_list); i++) { for (j=0; j<ms_kb_list[i].size; j++) { if (safe_strcmp(ms_kb_list[i].list[j], kb) == 0) { return i; } } } return -1; }
GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name) { GList *list = gncBillTermGetTerms (book); for ( ; list; list = list->next) { GncBillTerm *term = list->data; if (!safe_strcmp (term->name, name)) return list->data; } return NULL; }
static const char* kb_to_hr(const char* kb) { int i; for (i=0; i<ARRAYSIZE(kb_hr_list); i++) { if (safe_strcmp(kb, kb_hr_list[i][0]) == 0) { return kb_hr_list[i][1]; } } // Should never happen, so let's try to get some attention here MessageBoxA(hMainDialog, "YO BNLA #1", "UHAHAHHA?", MB_OKCANCEL|MB_ICONWARNING); return "Someone missed a keyboard!"; }
static const char* fd_get_kbdrv(const char* kb) { unsigned int i, j; for (i=0; i<ARRAYSIZE(fd_kb_list); i++) { for (j=0; j<fd_kb_list[i].size; j++) { if (safe_strcmp(fd_kb_list[i].list[j], kb) == 0) { return fd_kb_list[i].name; } } } return NULL; }
/* * Scan and set ISO properties * Returns true if the the current file does not need to be processed further */ static __inline BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL* is_old_vesamenu, int64_t i_file_length, const char* psz_basename, const char* psz_fullpath) { size_t i, j; // Check for an isolinux/syslinux config file anywhere *is_syslinux_cfg = FALSE; for (i=0; i<ARRAYSIZE(isolinux_name); i++) { if (safe_stricmp(psz_basename, isolinux_name[i]) == 0) *is_syslinux_cfg = TRUE; } // Check for an old vesamenu.c32 file anywhere *is_old_vesamenu = FALSE; if ((safe_stricmp(psz_basename, vesamenu_name) == 0) && (i_file_length <= old_vesamenu_threshold)) { *is_old_vesamenu = TRUE; } if (scan_only) { // Check for a "bootmgr" file in root (psz_path = "") if ((*psz_dirname == 0) && (safe_stricmp(psz_basename, bootmgr_name) == 0)) iso_report.has_bootmgr = TRUE; // Check for PE (XP) specific files in "/i386" or "/minint" for (i=0; i<ARRAYSIZE(pe_dirname); i++) if (safe_stricmp(psz_dirname, pe_dirname[i]) == 0) for (j=0; j<ARRAYSIZE(pe_file); j++) if (safe_stricmp(psz_basename, pe_file[j]) == 0) iso_report.winpe |= (1<<i)<<(ARRAYSIZE(pe_dirname)*j); if (*is_syslinux_cfg) { iso_report.has_isolinux = TRUE; // Maintain a list of all the isolinux/syslinux configs identified so far StrArrayAdd(&config_path, psz_fullpath); } if (*is_old_vesamenu) iso_report.has_old_vesamenu = TRUE; if (i_file_length >= FOUR_GIGABYTES) iso_report.has_4GB_file = TRUE; // Compute projected size needed total_blocks += i_file_length/UDF_BLOCKSIZE; // NB: ISO_BLOCKSIZE = UDF_BLOCKSIZE if ((i_file_length != 0) && (i_file_length%ISO_BLOCKSIZE == 0)) // total_blocks++; return TRUE; } // In case there's an ldlinux.sys on the ISO, prevent it from overwriting ours if ((*psz_dirname == 0) && (safe_strcmp(psz_basename, ldlinux_name) == 0)) { uprintf("skipping % file from ISO image\n", ldlinux_name); return TRUE; } return FALSE; }
void getStatusValue(char *type, char *retvalue) { if (!safe_strcmp(type, "ethmac")) { getMacByIntf("eth0", retvalue); } else if (!safe_strcmp(type, "wlan0")) { getMacByIntf("wlan0-va0", retvalue); } else if (!safe_strcmp(type, "wlan1")) { getMacByIntf("wlan1-va0", retvalue); } else if (!safe_strcmp(type, "mocamac")) { getMacByIntf("eth0", retvalue); } else if (!safe_strcmp(type, "version")) { strcpy(retvalue, "10.1.1"); } else if (!safe_strcmp(type, "ipv6addr")) { getIPv6Addr("br0", retvalue); } kinfo("%s -> %s", type, retvalue); }
int gncEntryCompare (const GncEntry *a, const GncEntry *b) { int compare; if (a == b) return 0; if (!a && b) return -1; if (a && !b) return 1; compare = timespec_cmp (&(a->date), &(b->date)); if (compare) return compare; compare = timespec_cmp (&(a->date_entered), &(b->date_entered)); if (compare) return compare; compare = safe_strcmp (a->desc, b->desc); if (compare) return compare; compare = safe_strcmp (a->action, b->action); if (compare) return compare; return qof_instance_guid_compare(a, b); }
int safe_strcoll(const char *s1, const char *s2) { #ifdef HAVE_STRCOLL if (s1 == NULL && s2 == NULL) return 0; if (s1 == NULL) return -1; if (s2 == NULL) return 1; return strcoll(s1, s2); #else /* fall back to strcmp */ return safe_strcmp(s1, s2); #endif }
int glsl_type::field_index(const char *name) const { if (this->base_type != GLSL_TYPE_STRUCT) return -1; for (unsigned i = 0; i < this->length; i++) { if (safe_strcmp(name, this->fields.structure[i].name) == 0) return i; } return -1; }
const glsl_type * glsl_type::field_type(const char *name) const { if (this->base_type != GLSL_TYPE_STRUCT) return error_type; for (unsigned i = 0; i < this->length; i++) { if (safe_strcmp(name, this->fields.structure[i].name) == 0) return this->fields.structure[i].type; } return error_type; }
void test_message_info (CamelMimeMessage *msg, const CamelMessageInfo *info) { check_msg (safe_strcmp (camel_message_info_subject (info), camel_mime_message_get_subject (msg)) == 0, "info->subject = '%s', get_subject () = '%s'", camel_message_info_subject (info), camel_mime_message_get_subject (msg)); /* FIXME: testing from/cc/to, etc is more tricky */ check (camel_message_info_date_sent (info) == camel_mime_message_get_date (msg, NULL)); /* date received isn't set for messages that haven't been sent anywhere ... */ /*check (info->date_received == camel_mime_message_get_date_received (msg, NULL));*/ /* so is messageid/references, etc */ }
static gboolean gnc_extension_type (SCM extension, GtkUIManagerItemType *type) { char *string; initialize_getters(); string = gnc_guile_call1_symbol_to_string(getters.type, extension); if (string == NULL) { PERR("bad type"); return FALSE; } if (safe_strcmp(string, "menu-item") == 0) { *type = GTK_UI_MANAGER_MENUITEM; } else if (safe_strcmp(string, "menu") == 0) { *type = GTK_UI_MANAGER_MENU; } else if (safe_strcmp(string, "separator") == 0) { *type = GTK_UI_MANAGER_SEPARATOR; } else { PERR("bad type"); return FALSE; } free(string); return TRUE; }
gboolean gnc_search_param_type_match (GNCSearchParam *a, GNCSearchParam *b) { GNCSearchParamPrivate *a_priv, *b_priv; g_return_val_if_fail (GNC_IS_SEARCH_PARAM (a), FALSE); g_return_val_if_fail (GNC_IS_SEARCH_PARAM (b), FALSE); a_priv = GNC_SEARCH_PARAM_GET_PRIVATE(a); b_priv = GNC_SEARCH_PARAM_GET_PRIVATE(b); if (a_priv->type == b_priv->type || !safe_strcmp (a_priv->type, b_priv->type)) return TRUE; return FALSE; }