static int get_stat_data(struct cache_entry *ce, const unsigned char **sha1p, unsigned int *modep, int cached, int match_missing) { const unsigned char *sha1 = ce->sha1; unsigned int mode = ce->ce_mode; if (!cached && !ce_uptodate(ce)) { int changed; struct stat st; changed = check_removed(ce, &st); if (changed < 0) return -1; else if (changed) { if (match_missing) { *sha1p = sha1; *modep = mode; return 0; } return -1; } changed = ce_match_stat(ce, &st, 0); if (changed) { mode = ce_mode_from_stat(ce, st.st_mode); sha1 = null_sha1; } } *sha1p = sha1; *modep = mode; return 0; }
static int get_stat_data(const struct cache_entry *ce, const struct object_id **oidp, unsigned int *modep, int cached, int match_missing, unsigned *dirty_submodule, struct diff_options *diffopt) { const struct object_id *oid = &ce->oid; unsigned int mode = ce->ce_mode; if (!cached && !ce_uptodate(ce)) { int changed; struct stat st; changed = check_removed(ce, &st); if (changed < 0) return -1; else if (changed) { if (match_missing) { *oidp = oid; *modep = mode; return 0; } return -1; } changed = match_stat_with_submodule(diffopt, ce, &st, 0, dirty_submodule); if (changed) { mode = ce_mode_from_stat(ce, st.st_mode); oid = &null_oid; } } *oidp = oid; *modep = mode; return 0; }
static void remove_contacts_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { GError *error = NULL; RemoveData *data = (RemoveData *) user_data; if (!e_book_client_remove_contacts_finish (E_BOOK_CLIENT (source_object), result, &error)) g_error ("remove contacts finish: %s", error->message); check_removed (E_BOOK_CLIENT (source_object), data->uids); g_main_loop_quit (data->loop); }
static int get_stat_data(struct cache_entry *ce, const unsigned char **sha1p, unsigned int *modep, int cached, int match_missing, unsigned *dirty_submodule, struct diff_options *diffopt) { const unsigned char *sha1 = ce->sha1; unsigned int mode = ce->ce_mode; if (!cached && !ce_uptodate(ce)) { int changed; struct stat st; changed = check_removed(ce, &st); if (changed < 0) return -1; else if (changed) { if (match_missing) { *sha1p = sha1; *modep = mode; return 0; } return -1; } changed = ce_match_stat(ce, &st, 0); if (S_ISGITLINK(ce->ce_mode) && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES) && (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH)) && is_submodule_modified(ce->name)) { changed = 1; *dirty_submodule = 1; } if (changed) { mode = ce_mode_from_stat(ce, st.st_mode); sha1 = null_sha1; } } *sha1p = sha1; *modep = mode; return 0; }
static void test_remove_contacts_sync (ETestServerFixture *fixture, gconstpointer user_data) { EBookClient *book_client; GError *error = NULL; GSList *uids = NULL; book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient); if (!fill_book_client (book_client, &uids)) g_error ("Failed to add contacts"); if (!e_book_client_remove_contacts_sync (book_client, uids, NULL, &error)) g_error ("remove contact sync: %s", error->message); /* This will assert they are actually removed */ check_removed (book_client, uids); g_slist_foreach (uids, (GFunc) g_free, NULL); g_slist_free (uids); }
int run_diff_files(struct rev_info *revs, unsigned int option) { int entries, i; int diff_unmerged_stage = revs->max_count; int silent_on_removed = option & DIFF_SILENT_ON_REMOVED; unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED) ? CE_MATCH_RACY_IS_DIRTY : 0); diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/"); if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = active_nr; for (i = 0; i < entries; i++) { struct stat st; unsigned int oldmode, newmode; struct cache_entry *ce = active_cache[i]; int changed; if (DIFF_OPT_TST(&revs->diffopt, QUIET) && DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) break; if (!ce_path_match(ce, revs->prune_data)) continue; if (ce_stage(ce)) { struct combine_diff_path *dpath; int num_compare_stages = 0; size_t path_len; path_len = ce_namelen(ce); dpath = xmalloc(combine_diff_path_size(5, path_len)); dpath->path = (char *) &(dpath->parent[5]); dpath->next = NULL; dpath->len = path_len; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; hashclr(dpath->sha1); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); changed = check_removed(ce, &st); if (!changed) dpath->mode = ce_mode_from_stat(ce, st.st_mode); else { if (changed < 0) { perror(ce->name); continue; } if (silent_on_removed) continue; } while (i < entries) { struct cache_entry *nce = active_cache[i]; int stage; if (strcmp(ce->name, nce->name)) break; /* Stage #2 (ours) is the first parent, * stage #3 (theirs) is the second. */ stage = ce_stage(nce); if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; hashcpy(dpath->parent[stage-2].sha1, nce->sha1); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; } /* diff against the proper unmerged stage */ if (stage == diff_unmerged_stage) ce = nce; i++; } /* * Compensate for loop update */ i--; if (revs->combine_merges && num_compare_stages == 2) { show_combined_diff(dpath, 2, revs->dense_combined_merges, revs); free(dpath); continue; } free(dpath); dpath = NULL; /* * Show the diff for the 'ce' if we found the one * from the desired stage. */ diff_unmerge(&revs->diffopt, ce->name, 0, null_sha1); if (ce_stage(ce) != diff_unmerged_stage) continue; } if (ce_uptodate(ce)) continue; changed = check_removed(ce, &st); if (changed) { if (changed < 0) { perror(ce->name); continue; } if (silent_on_removed) continue; diff_addremove(&revs->diffopt, '-', ce->ce_mode, ce->sha1, ce->name); continue; } changed = ce_match_stat(ce, &st, ce_option); if (!changed) { ce_mark_uptodate(ce); if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) continue; } oldmode = ce->ce_mode; newmode = ce_mode_from_stat(ce, st.st_mode); diff_change(&revs->diffopt, oldmode, newmode, ce->sha1, (changed ? null_sha1 : ce->sha1), ce->name); } diffcore_std(&revs->diffopt); diff_flush(&revs->diffopt); return 0; }
// TODO: allow commandline options (v2) // TODO: remove existing infs for similar devices (v2) int __cdecl main(int argc_ansi, char** argv_ansi) { DWORD r; BOOL b; int i, ret, argc = argc_ansi, si=0; char** argv = argv_ansi; wchar_t **wenv, **wargv; char* hardware_id = NULL; char* device_id = NULL; char* user_sid = NULL; char* inf_name = NULL; char path[MAX_PATH_LENGTH]; char destname[MAX_PATH_LENGTH]; uintptr_t syslog_reader_thid = -1L; // Connect to the messaging pipe pipe_handle = CreateFileA(INSTALLER_PIPE_NAME, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, NULL); if (pipe_handle == INVALID_HANDLE_VALUE) { // If we can't connect to the pipe, someone is probably trying to run us standalone printf("This application can not be run from the command line.\n"); printf("Please use your initial installer application if you want to install the driver.\n"); return WDI_ERROR_NOT_SUPPORTED; } if (init_dlls()) { plog("could not init DLLs"); ret = WDI_ERROR_RESOURCE; goto out; } // Initialize COM for Restore Point disabling CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); // libwdi provides the arguments as UTF-16 => read them and convert to UTF-8 if (__wgetmainargs != NULL) { __wgetmainargs(&argc, &wargv, &wenv, 1, &si); argv = calloc(argc, sizeof(char*)); for (i=0; i<argc; i++) { argv[i] = wchar_to_utf8(wargv[i]); } } else { plog("unable to access UTF-16 args - trying ANSI"); } if (argc < 2) { printf("usage: %s <inf_name>\n", argv[0]); plog("missing inf_name parameter"); } inf_name = argv[1]; plog("got parameter %s", argv[1]); r = GetFullPathNameU(".", MAX_PATH_LENGTH, path, NULL); if ((r == 0) || (r > MAX_PATH_LENGTH)) { plog("could not retrieve absolute path of working directory"); ret = WDI_ERROR_ACCESS; goto out; } safe_strcat(path, MAX_PATH_LENGTH, "\\"); safe_strcat(path, MAX_PATH_LENGTH, inf_name); device_id = req_id(IC_GET_DEVICE_ID); hardware_id = req_id(IC_GET_HARDWARE_ID); // Will be used if we ever need to create a file, as the original user, from this app user_sid = req_id(IC_GET_USER_SID); ConvertStringSidToSidA(user_sid, &user_psid); // Setup the syslog reader thread syslog_ready_event = CreateEvent(NULL, TRUE, FALSE, NULL); syslog_terminate_event = CreateEvent(NULL, TRUE, FALSE, NULL); syslog_reader_thid = _beginthread(syslog_reader_thread, 0, 0); if ( (syslog_reader_thid == -1L) || (WaitForSingleObject(syslog_ready_event, 2000) != WAIT_OBJECT_0) ) { plog("Unable to create syslog reader thread"); SetEvent(syslog_terminate_event); // NB: if you try to close the syslog reader thread handle, you get a // "more recent driver was found" error from UpdateForPnP. Weird... } // Disable the creation of a restore point disable_system_restore(true); // Find if the device is plugged in send_status(IC_SET_TIMEOUT_INFINITE); if (hardware_id != NULL) { plog("Installing driver for %s - please wait...", hardware_id); b = UpdateDriverForPlugAndPlayDevicesU(NULL, hardware_id, path, INSTALLFLAG_FORCE, NULL); send_status(IC_SET_TIMEOUT_DEFAULT); if (b == true) { // Success plog("driver update completed"); enumerate_device(device_id); ret = WDI_SUCCESS; goto out; } ret = process_error(GetLastError(), path); if (ret != WDI_SUCCESS) { goto out; } } // TODO: try URL for OEMSourceMediaLocation (v2) plog("Copying inf file (for the next time device is plugged) - please wait..."); send_status(IC_SET_TIMEOUT_INFINITE); b = SetupCopyOEMInfU(path, NULL, SPOST_PATH, 0, destname, MAX_PATH_LENGTH, NULL, NULL); send_status(IC_SET_TIMEOUT_DEFAULT); if (b) { plog("copied inf to %s", destname); ret = WDI_SUCCESS; enumerate_device(device_id); goto out; } ret = process_error(GetLastError(), path); if (ret != WDI_SUCCESS) { goto out; } // If needed, flag removed devices for reinstallation. see: // http://msdn.microsoft.com/en-us/library/aa906206.aspx check_removed(hardware_id); out: // Report any error status code and wait for target app to read it send_status(IC_INSTALLER_COMPLETED); pstat(ret); // Restore the system restore point creation original settings disable_system_restore(false); // TODO: have libwi send an ACK? Sleep(1000); SetEvent(syslog_terminate_event); if (argv != argv_ansi) { for (i=0; i<argc; i++) { safe_free(argv[i]); } safe_free(argv); } CloseHandle(syslog_ready_event); CloseHandle(syslog_terminate_event); CloseHandle((HANDLE)syslog_reader_thid); CloseHandle(pipe_handle); return ret; }
int run_diff_files(struct rev_info *revs, unsigned int option) { int entries, i; int diff_unmerged_stage = revs->max_count; unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED) ? CE_MATCH_RACY_IS_DIRTY : 0); diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/"); if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = active_nr; for (i = 0; i < entries; i++) { unsigned int oldmode, newmode; struct cache_entry *ce = active_cache[i]; int changed; unsigned dirty_submodule = 0; const unsigned char *old_sha1, *new_sha1; if (diff_can_quit_early(&revs->diffopt)) break; if (!ce_path_match(ce, &revs->prune_data, NULL)) continue; if (ce_stage(ce)) { struct combine_diff_path *dpath; struct diff_filepair *pair; unsigned int wt_mode = 0; int num_compare_stages = 0; size_t path_len; struct stat st; path_len = ce_namelen(ce); dpath = xmalloc(combine_diff_path_size(5, path_len)); dpath->path = (char *) &(dpath->parent[5]); dpath->next = NULL; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; oidclr(&dpath->oid); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); changed = check_removed(ce, &st); if (!changed) wt_mode = ce_mode_from_stat(ce, st.st_mode); else { if (changed < 0) { perror(ce->name); continue; } wt_mode = 0; } dpath->mode = wt_mode; while (i < entries) { struct cache_entry *nce = active_cache[i]; int stage; if (strcmp(ce->name, nce->name)) break; /* Stage #2 (ours) is the first parent, * stage #3 (theirs) is the second. */ stage = ce_stage(nce); if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; hashcpy(dpath->parent[stage-2].oid.hash, nce->sha1); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; } /* diff against the proper unmerged stage */ if (stage == diff_unmerged_stage) ce = nce; i++; } /* * Compensate for loop update */ i--; if (revs->combine_merges && num_compare_stages == 2) { show_combined_diff(dpath, 2, revs->dense_combined_merges, revs); free(dpath); continue; } free(dpath); dpath = NULL; /* * Show the diff for the 'ce' if we found the one * from the desired stage. */ pair = diff_unmerge(&revs->diffopt, ce->name); if (wt_mode) pair->two->mode = wt_mode; if (ce_stage(ce) != diff_unmerged_stage) continue; } if (ce_uptodate(ce) || ce_skip_worktree(ce)) continue; /* If CE_VALID is set, don't look at workdir for file removal */ if (ce->ce_flags & CE_VALID) { changed = 0; newmode = ce->ce_mode; } else { struct stat st; changed = check_removed(ce, &st); if (changed) { if (changed < 0) { perror(ce->name); continue; } diff_addremove(&revs->diffopt, '-', ce->ce_mode, ce->sha1, !is_null_sha1(ce->sha1), ce->name, 0); continue; } changed = match_stat_with_submodule(&revs->diffopt, ce, &st, ce_option, &dirty_submodule); newmode = ce_mode_from_stat(ce, st.st_mode); } if (!changed && !dirty_submodule) { ce_mark_uptodate(ce); if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) continue; } oldmode = ce->ce_mode; old_sha1 = ce->sha1; new_sha1 = changed ? null_sha1 : ce->sha1; diff_change(&revs->diffopt, oldmode, newmode, old_sha1, new_sha1, !is_null_sha1(old_sha1), !is_null_sha1(new_sha1), ce->name, 0, dirty_submodule); } diffcore_std(&revs->diffopt); diff_flush(&revs->diffopt); return 0; }
int run_diff_files(struct rev_info *revs, unsigned int option) { int entries, i; int diff_unmerged_stage = revs->max_count; unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED) ? CE_MATCH_RACY_IS_DIRTY : 0); uint64_t start = getnanotime(); struct index_state *istate = revs->diffopt.repo->index; diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/"); if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = istate->cache_nr; for (i = 0; i < entries; i++) { unsigned int oldmode, newmode; struct cache_entry *ce = istate->cache[i]; int changed; unsigned dirty_submodule = 0; const struct object_id *old_oid, *new_oid; if (diff_can_quit_early(&revs->diffopt)) break; if (!ce_path_match(istate, ce, &revs->prune_data, NULL)) continue; if (ce_stage(ce)) { struct combine_diff_path *dpath; struct diff_filepair *pair; unsigned int wt_mode = 0; int num_compare_stages = 0; size_t path_len; struct stat st; path_len = ce_namelen(ce); dpath = xmalloc(combine_diff_path_size(5, path_len)); dpath->path = (char *) &(dpath->parent[5]); dpath->next = NULL; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; oidclr(&dpath->oid); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); changed = check_removed(ce, &st); if (!changed) wt_mode = ce_mode_from_stat(ce, st.st_mode); else { if (changed < 0) { perror(ce->name); continue; } wt_mode = 0; } dpath->mode = wt_mode; while (i < entries) { struct cache_entry *nce = istate->cache[i]; int stage; if (strcmp(ce->name, nce->name)) break; /* Stage #2 (ours) is the first parent, * stage #3 (theirs) is the second. */ stage = ce_stage(nce); if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; oidcpy(&dpath->parent[stage - 2].oid, &nce->oid); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; } /* diff against the proper unmerged stage */ if (stage == diff_unmerged_stage) ce = nce; i++; } /* * Compensate for loop update */ i--; if (revs->combine_merges && num_compare_stages == 2) { show_combined_diff(dpath, 2, revs->dense_combined_merges, revs); free(dpath); continue; } FREE_AND_NULL(dpath); /* * Show the diff for the 'ce' if we found the one * from the desired stage. */ pair = diff_unmerge(&revs->diffopt, ce->name); if (wt_mode) pair->two->mode = wt_mode; if (ce_stage(ce) != diff_unmerged_stage) continue; } if (ce_uptodate(ce) || ce_skip_worktree(ce)) continue; /* If CE_VALID is set, don't look at workdir for file removal */ if (ce->ce_flags & CE_VALID) { changed = 0; newmode = ce->ce_mode; } else { struct stat st; changed = check_removed(ce, &st); if (changed) { if (changed < 0) { perror(ce->name); continue; } diff_addremove(&revs->diffopt, '-', ce->ce_mode, &ce->oid, !is_null_oid(&ce->oid), ce->name, 0); continue; } else if (revs->diffopt.ita_invisible_in_index && ce_intent_to_add(ce)) { diff_addremove(&revs->diffopt, '+', ce->ce_mode, the_hash_algo->empty_tree, 0, ce->name, 0); continue; } changed = match_stat_with_submodule(&revs->diffopt, ce, &st, ce_option, &dirty_submodule); newmode = ce_mode_from_stat(ce, st.st_mode); } if (!changed && !dirty_submodule) { ce_mark_uptodate(ce); mark_fsmonitor_valid(ce); if (!revs->diffopt.flags.find_copies_harder) continue; } oldmode = ce->ce_mode; old_oid = &ce->oid; new_oid = changed ? &null_oid : &ce->oid; diff_change(&revs->diffopt, oldmode, newmode, old_oid, new_oid, !is_null_oid(old_oid), !is_null_oid(new_oid), ce->name, 0, dirty_submodule); } diffcore_std(&revs->diffopt); diff_flush(&revs->diffopt); trace_performance_since(start, "diff-files"); return 0; }