Exemple #1
0
static void do_fwd_mangled_map(char *s, char *MangledMap)
{
    /* MangledMap is a series of name pairs in () separated by spaces.
     * If s matches the first of the pair then the name given is the
     * second of the pair.  A * means any number of any character and if
     * present in the second of the pair as well as the first the
     * matching part of the first string takes the place of the * in the
     * second.
     *
     * I wanted this so that we could have RCS files which can be used
     * by UNIX and DOS programs.  My mapping string is (RCS rcs) which
     * converts the UNIX RCS file subdirectory to lowercase thus
     * preventing mangling.
     */
    char *start=MangledMap;       /* Use this to search for mappings. */
    char *end;                    /* Used to find the end of strings. */
    char *match_string;
    pstring new_string;           /* Make up the result here. */
    char *np;                     /* Points into new_string. */

    DEBUG(5,("Mangled Mapping '%s' map '%s'\n", s, MangledMap));
    while (*start) {
        while ((*start) && (*start != '('))
            start++;
        start++;                    /* Skip the ( */
        if (!*start)
            continue;                 /* Always check for the end. */
        end = start;                /* Search for the ' ' or a ')' */
        DEBUG(5,("Start of first in pair '%s'\n", start));
        while ((*end) && !((*end == ' ') || (*end == ')')))
            end++;
        if (!*end) {
            start = end;
            continue;                 /* Always check for the end. */
        }
        DEBUG(5,("End of first in pair '%s'\n", end));
        if ((match_string = map_filename(s, start, end-start))) {
            DEBUG(5,("Found a match\n"));
            /* Found a match. */
            start = end+1;            /* Point to start of what it is to become. */
            DEBUG(5,("Start of second in pair '%s'\n", start));
            end = start;
            np = new_string;
            while ((*end)             /* Not the end of string. */
                    && (*end != ')')   /* Not the end of the pattern. */
                    && (*end != '*'))  /* Not a wildcard. */
                *np++ = *end++;
            if (!*end) {
                start = end;
                continue;               /* Always check for the end. */
            }
            if (*end == '*') {
                strcpy(np, match_string);
                np += strlen(match_string);
                end++;                  /* Skip the '*' */
                while ((*end)             /* Not the end of string. */
                        && (*end != ')')   /* Not the end of the pattern. */
                        && (*end != '*'))  /* Not a wildcard. */
                    *np++ = *end++;
            }
            if (!*end) {
                start = end;
                continue;               /* Always check for the end. */
            }
            *np++ = '\0';             /* NULL terminate it. */
            DEBUG(5,("End of second in pair '%s'\n", end));
            strcpy(s, new_string);    /* Substitute with the new name. */
            DEBUG(5,("s is now '%s'\n", s));
        }
        start = end;              /* Skip a bit which cannot be wanted */
        /* anymore. */
        start++;
    }
}
Exemple #2
0
/* ************************************************************************** **
 * MangledMap is a series of name pairs in () separated by spaces.
 * If s matches the first of the pair then the name given is the
 * second of the pair.  A * means any number of any character and if
 * present in the second of the pair as well as the first the
 * matching part of the first string takes the place of the * in the
 * second.
 *
 * I wanted this so that we could have RCS files which can be used
 * by UNIX and DOS programs.  My mapping string is (RCS rcs) which
 * converts the UNIX RCS file subdirectory to lowercase thus
 * preventing mangling.
 *
 * See 'mangled map' in smb.conf(5).
 *
 * ************************************************************************** **
 */
static void mangled_map(char *s, const char *MangledMap)
{
	const char *start=MangledMap;       /* Use this to search for mappings. */
	const char *end;                    /* Used to find the end of strings. */
	char *match_string;
	pstring new_string;           /* Make up the result here. */
	char *np;                     /* Points into new_string. */

	DEBUG( 5, ("Mangled Mapping '%s' map '%s'\n", s, MangledMap) );
	while( *start ) {
		while( (*start) && (*start != '(') )
			start++;
		if( !*start )
			continue;                 /* Always check for the end. */
		start++;                    /* Skip the ( */
		end = start;                /* Search for the ' ' or a ')' */
		DEBUG( 5, ("Start of first in pair '%s'\n", start) );
		while( (*end) && !((*end == ' ') || (*end == ')')) )
			end++;
		if( !*end ) {
			start = end;
			continue;                 /* Always check for the end. */
		}
		DEBUG( 5, ("End of first in pair '%s'\n", end) );
		if( (match_string = map_filename( s, start, end-start )) ) {
			int size_left = sizeof(new_string) - 1;
			DEBUG( 5, ("Found a match\n") );
			/* Found a match. */
			start = end + 1; /* Point to start of what it is to become. */
			DEBUG( 5, ("Start of second in pair '%s'\n", start) );
			end = start;
			np = new_string;
			while( (*end && size_left > 0)    /* Not the end of string. */
			       && (*end != ')')      /* Not the end of the pattern. */
			       && (*end != '*') ) {   /* Not a wildcard. */
				*np++ = *end++;
				size_left--;
			}

			if( !*end ) {
				start = end;
				continue;               /* Always check for the end. */
			}
			if( *end == '*' ) {
				if (size_left > 0 )
					safe_strcpy( np, match_string, size_left );
				np += strlen( match_string );
				size_left -= strlen( match_string );
				end++;                  /* Skip the '*' */
				while ((*end && size_left >  0)   /* Not the end of string. */
				       && (*end != ')') /* Not the end of the pattern. */
				       && (*end != '*')) { /* Not a wildcard. */
					*np++ = *end++;
					size_left--;
				}
			}
			if (!*end) {
				start = end;
				continue;               /* Always check for the end. */
			}
			if (size_left > 0)
				*np++ = '\0';             /* NULL terminate it. */
			DEBUG(5,("End of second in pair '%s'\n", end));
			new_string[sizeof(new_string)-1] = '\0';
			pstrcpy( s, new_string );  /* Substitute with the new name. */
			DEBUG( 5, ("s is now '%s'\n", s) );
		}
		start = end;  /* Skip a bit which cannot be wanted anymore. */
		start++;
	}
}
Exemple #3
0
/*
 * Process each of the files in the list with the callback proc
 */
static int do_file_proc (Node *p, void *closure)
{
    struct frame_and_file *frfile = (struct frame_and_file *)closure;
    struct file_info *finfo = frfile->finfo;
    int ret;
	Entnode *e;
	const char *mapped_name;
	const char *mapped_file_repository = NULL;

	if(!current_parsed_root->isremote)
		mapped_name = map_filename(finfo->virtual_repository, p->key, &mapped_file_repository);
	else
		mapped_name = xstrdup(p->key);

	finfo->file = p->key;
	finfo->mapped_file = mapped_name;

	char *ff = (char*)xmalloc (strlen (finfo->file)
			       + strlen (finfo->update_dir)
			       + 2);
	finfo->fullname = ff;
    ff[0] = '\0';
    if (finfo->update_dir[0] != '\0')
    {
		strcat (ff, finfo->update_dir);
		strcat (ff, "/");
    }
    strcat (ff, finfo->file);

    if (frfile->frame->dosrcs && mapped_file_repository)
    {
	finfo->rcs = RCS_parse (finfo->mapped_file, mapped_file_repository);

	/* OK, without W_LOCAL the error handling becomes relatively
	   simple.  The file names came from readdir() on the
	   repository and so we know any ENOENT is an error
	   (e.g. symlink pointing to nothing).  Now, the logic could
	   be simpler - since we got the name from readdir, we could
	   just be calling RCS_parsercsfile.  */
	if (finfo->rcs == NULL
	    && !(frfile->frame->which & W_LOCAL))
	{
	    error (0, 0, "could not read RCS file for %s", fn_root(finfo->fullname));
	    xfree (finfo->fullname);
	    cvs_flushout ();
	    return 0;
	}
    }
    else 
        finfo->rcs = (RCSNode *) NULL;

	p = findnode_fn(finfo->entries,finfo->file);
	if(p)
	{
		const char *message;
		const char *v_type;

		e = (Entnode *)p->data;

		if (! verify_access(frfile->frame->permproc, finfo->repository, finfo->file, finfo->update_dir, e->tag, &message, &v_type))
		{
			if(e->tag && !quiet && !(frfile->frame->which&W_QUIET))
				error (0, 0, "User %s is unable to %s %s/%s on branch/tag %s",CVS_Username,v_type,finfo->update_dir,finfo->file,e->tag);
			else if(!quiet && !(frfile->frame->which&W_QUIET))
				error (0, 0, "User %s is unable to %s %s/%s",CVS_Username,v_type,finfo->update_dir,finfo->file);
			if(message && !quiet && !(frfile->frame->which&W_QUIET))
				error (0, 0, "%s", message);
			ret = 1;
		}
		else
			ret = frfile->frame->fileproc (frfile->frame->callerdat, finfo);
	}
	else
		ret = frfile->frame->fileproc (frfile->frame->callerdat, finfo);

    freercsnode(&finfo->rcs);
    xfree (finfo->fullname);
	xfree (mapped_name);
	xfree (mapped_file_repository);

    /* Allow the user to monitor progress with tail -f.  Doing this once
       per file should be no big deal, but we don't want the performance
       hit of flushing on every line like previous versions of CVS.  */
    cvs_flushout ();

    return (ret);
}