コード例 #1
0
ファイル: triglib.c プロジェクト: samdunne/dpkg-diversions
static void
trk_explicit_interest_change(const char *trig,  struct pkginfo *pkg, int signum,
                             enum trig_options opts)
{
	static struct varbuf newfn;
	char buf[1024];
	FILE *nf;
	bool empty = true;

	trk_explicit_start(trig);
	varbuf_reset(&newfn);
	varbuf_printf(&newfn, "%s/%s.new", triggersdir, trig);

	nf = fopen(newfn.buf, "w");
	if (!nf)
		ohshite(_("unable to create new trigger interest file `%.250s'"),
		        newfn.buf);
	push_cleanup(cu_closestream, ~ehflag_normaltidy, NULL, 0, 1, nf);

	while (trk_explicit_f && trk_explicit_fgets(buf, sizeof(buf)) >= 0) {
		int len = strlen(pkg->name);
		if (strncmp(buf, pkg->name, len) == 0 &&
		    (buf[len] == '\0' || buf[len] == '/'))
			continue;
		fprintf(nf, "%s\n", buf);
		empty = false;
	}
	if (signum > 0) {
		fprintf(nf, "%s%s\n", pkg->name,
		        (opts == trig_noawait) ? "/noawait" : "");
		empty = false;
	}

	if (!empty)
		trk_explicit_interest_flush(newfn.buf, nf);

	pop_cleanup(ehflag_normaltidy);
	if (fclose(nf))
		ohshite(_("unable to close new trigger interest file `%.250s'"),
		        newfn.buf);

	if (empty)
		trk_explicit_interest_remove(newfn.buf);
	else
		trk_explicit_interest_commit(newfn.buf);

	dir_sync_path(triggersdir);
}
コード例 #2
0
ファイル: triglib.c プロジェクト: guillemj/dpkg
static void
trk_explicit_interest_change(const char *trig,  struct pkginfo *pkg,
                             struct pkgbin *pkgbin, int signum,
                             enum trig_options opts)
{
	char buf[1024];
	struct atomic_file *file;
	bool empty = true;

	trk_explicit_start(trig);
	file = atomic_file_new(trk_explicit_fn.buf, 0);
	atomic_file_open(file);

	while (trk_explicit_f && trk_explicit_fgets(buf, sizeof(buf)) >= 0) {
		const char *pkgname = pkgbin_name(pkg, pkgbin, pnaw_nonambig);
		size_t len = strlen(pkgname);

		if (strncmp(buf, pkgname, len) == 0 && len < sizeof(buf) &&
		    (buf[len] == '\0' || buf[len] == '/'))
			continue;
		fprintf(file->fp, "%s\n", buf);
		empty = false;
	}
	if (signum > 0) {
		fprintf(file->fp, "%s%s\n",
		        pkgbin_name(pkg, pkgbin, pnaw_nonambig),
		        (opts == TRIG_NOAWAIT) ? "/noawait" : "");
		empty = false;
	}

	if (!empty)
		atomic_file_sync(file);

	atomic_file_close(file);

	if (empty)
		atomic_file_remove(file);
	else
		atomic_file_commit(file);

	atomic_file_free(file);

	dir_sync_path(triggersdir);
}
コード例 #3
0
ファイル: triglib.c プロジェクト: guillemj/dpkg
static void
trk_explicit_activate_start(void)
{
	trk_explicit_start(trig_activating_name);
	trk_explicit_trig = trig_activating_name;
}
コード例 #4
0
ファイル: triglib.c プロジェクト: samdunne/dpkg-diversions
static void
trk_explicit_activate_start(void)
{
	trk_explicit_start(trig_activating_name);
	trk_explicit_trig = nfstrsave(trig_activating_name);
}