예제 #1
0
static struct object_version_s *
version_getslen(gboolean init, GTree *t, const guint8 *ks, gsize ks_len)
{
	hashstr_t *k = hashstr_printf("%.*s", ks_len, ks);
	struct object_version_s *o = version_get(init, t, k);
	g_free(k);
	return o;
}
예제 #2
0
void version_print(freed_bstring application)
{
    bstring ver = version_get();

    if (debug_getlevel() < LEVEL_VERBOSE)
    {
        bdestroy(ver);
        bautodestroy(application);
        return;
    }

    fprintf(stderr, "DCPU-16 Toolchain ");
    fprintf(stderr, "%s", application.ref->data);
    fprintf(stderr, " (");
    fprintf(stderr, "%s", ver->data);
    fprintf(stderr, ")\n");
    fprintf(stderr, "This software is MIT licensed.\n");
    fprintf(stderr, "\n");

    bdestroy(ver);
    bautodestroy(application);
}
예제 #3
0
bool version_increment(string filename) {
    int v1 = 1, v2 = 0, v3 = 0;
    //pobranie numeru wersji
    if (!version_get(filename, v1, v2, v3))
        return false;
    //zwiększenie wersji
    v3++;
    if (v3 >= 100) {
        v3 = 0;
        v2++;
    }
    if (v2 >= 100) {
        v2 = 0;
        v1++;
    }
    if (version_save(filename, v1, v2, v3)) {
        stringstream ss;
        ss << "Zwiekszono numer kolejnej wersji na: " << v1 << "." << v2 << "." << v3;
        Log::info(ss.str());
        return true;
    } else {
        return false;
    }
}
예제 #4
0
void
	get_input_file (char const *filename, char const *outname)
{
	bool elsewhere = strcmp (filename, outname) != 0;
	char const *cs;
	char *diffbuf;
	char *getbuf;

	if (inerrno == -1)
		inerrno = stat (inname, &instat) == 0 ? 0 : errno;

	/* Perhaps look for RCS or SCCS versions.  */
	if (patch_get
		&& invc != 0
		&& (inerrno
		|| (! elsewhere
		&& (/* No one can write to it.  */
		(instat.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) == 0
		/* Only the owner (who's not me) can write to it.  */
		|| ((instat.st_mode & (S_IWGRP|S_IWOTH)) == 0
		&& instat.st_uid != geteuid ()))))
		&& (invc = !! (cs = (version_controller
		(filename, elsewhere,
		inerrno ? (struct stat *) 0 : &instat,
		&getbuf, &diffbuf))))) {

			if (!inerrno) {
				if (!elsewhere
					&& (instat.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) != 0)
					/* Somebody can write to it.  */
					fatal ("File %s seems to be locked by somebody else under %s",
					quotearg (filename), cs);
				if (diffbuf)
				{
					/* It might be checked out unlocked.  See if it's safe to
					check out the default version locked.  */

					if (verbosity == VERBOSE)
						say ("Comparing file %s to default %s version...\n",
						quotearg (filename), cs);

					if (systemic (diffbuf) != 0)
					{
						say ("warning: Patching file %s, which does not match default %s version\n",
							quotearg (filename), cs);
						cs = 0;
					}
				}
			}

			if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
				&instat))
				inerrno = 0;

			free (getbuf);
			if (diffbuf)
				free (diffbuf);

	} else if (inerrno && !pch_says_nonexistent (reverse))
	{
		errno = inerrno;
		pfatal ("Can't find file %s", quotearg (filename));
	}

	if (inerrno)
	{
		instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
		instat.st_size = 0;
	}
	else if (! S_ISREG (instat.st_mode))
		fatal ("File %s is not a regular file -- can't patch",
		quotearg (filename));
}