コード例 #1
0
	static  void pw_sort(vec<Formula>& toSort,int n,int startPos) {
			if (n == 1) return;
			else {
				split(toSort,n, startPos); 
				pw_sort(toSort,n/2, startPos);
				pw_sort(toSort,n/2, startPos+n/2);
				pw_merge(toSort,n, startPos, 1);
			}
	}
コード例 #2
0
void pw_sort(vec<Formula>& fs) {
		int orig_sz = fs.size();
    	int sz; for (sz = 1; sz < fs.size(); sz *= 2);
    	fs.growTo(sz,_0_);
		pw_sort(fs,sz, 0);
		fs.shrink(sz - orig_sz);
}
コード例 #3
0
static
void buildSorter(vec<Formula>& ps, vec<int>& Cs, vec<Formula>& out_sorter, PBOptions* options)
{
    out_sorter.clear();
    for (int i = 0; i < ps.size(); i++)
        for (int j = 0; j < Cs[i]; j++)
            out_sorter.push(ps[i]);
    if (options->opt_sorting_network_encoding==pairwiseSortEncoding)
    	pw_sort(out_sorter);
    else
    	oddEvenSort(out_sorter); // (overwrites inputs)
}
コード例 #4
0
ファイル: pwck.c プロジェクト: justinc1985/IntelRangeley
/*
 * pwck - verify password file integrity
 */
int main (int argc, char **argv)
{
	int errors = 0;
	bool changed = false;

	/*
	 * Get my name so that I can use it to report errors.
	 */
	Prog = Basename (argv[0]);

	(void) setlocale (LC_ALL, "");
	(void) bindtextdomain (PACKAGE, LOCALEDIR);
	(void) textdomain (PACKAGE);

	OPENLOG ("pwck");

	/* Parse the command line arguments */
	process_flags (argc, argv);

	open_files ();

	if (sort_mode) {
		if (pw_sort () != 0) {
			fprintf (stderr,
			         _("%s: cannot sort entries in %s\n"),
			         Prog, pw_dbname ());
			fail_exit (E_CANTSORT);
		}
		if (is_shadow) {
			if (spw_sort () != 0) {
				fprintf (stderr,
				         _("%s: cannot sort entries in %s\n"),
				         Prog, spw_dbname ());
				fail_exit (E_CANTSORT);
			}
		}
		changed = true;
	} else {
		check_pw_file (&errors, &changed);

		if (is_shadow) {
			check_spw_file (&errors, &changed);
		}
	}

	close_files (changed);

	nscd_flush_cache ("passwd");

	/*
	 * Tell the user what we did and exit.
	 */
	if (0 != errors) {
		printf (changed ?
		        _("%s: the files have been updated\n") :
		        _("%s: no changes\n"), Prog);
	}

	closelog ();
	return ((0 != errors) ? E_BADENTRY : E_OKAY);
}