2000-10-09 00:36:55 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2000 Stephen Williams (steve@picturel.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2003-11-13 05:09:49 +01:00
|
|
|
#ident "$Id: build_string.c,v 1.15 2003/11/13 04:09:49 steve Exp $"
|
2000-10-09 00:36:55 +02:00
|
|
|
#endif
|
|
|
|
|
|
2001-07-25 05:10:48 +02:00
|
|
|
# include "config.h"
|
|
|
|
|
|
2000-10-09 00:36:55 +02:00
|
|
|
# include "globals.h"
|
|
|
|
|
# include <string.h>
|
|
|
|
|
# include <assert.h>
|
|
|
|
|
|
|
|
|
|
int build_string(char*output, size_t olen, const char*pattern)
|
|
|
|
|
{
|
|
|
|
|
char tmp_buf[1024];
|
|
|
|
|
|
|
|
|
|
char*output_save = output;
|
|
|
|
|
while (*pattern) {
|
|
|
|
|
|
|
|
|
|
if (*pattern == '%') {
|
|
|
|
|
pattern += 1;
|
|
|
|
|
switch (*pattern) {
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '%':
|
|
|
|
|
*output++ = '%';
|
|
|
|
|
break;
|
|
|
|
|
|
2000-10-28 05:45:47 +02:00
|
|
|
case '[': {
|
2000-10-09 00:36:55 +02:00
|
|
|
const char*tail;
|
|
|
|
|
pattern += 1;
|
|
|
|
|
assert(*pattern);
|
2000-10-28 05:45:47 +02:00
|
|
|
tail = strchr(pattern+1, ']');
|
2000-10-09 00:36:55 +02:00
|
|
|
assert(tail);
|
|
|
|
|
strncpy(tmp_buf, pattern+1, tail-pattern-1);
|
|
|
|
|
tmp_buf[tail-pattern-1] = 0;
|
|
|
|
|
|
2003-09-22 03:12:08 +02:00
|
|
|
if (((*pattern == 'v') && verbose_flag)
|
|
|
|
|
|| ((*pattern == 'N') && npath)) {
|
2000-10-09 00:36:55 +02:00
|
|
|
int rc = build_string(output, olen,
|
|
|
|
|
tmp_buf);
|
|
|
|
|
output += rc;
|
|
|
|
|
olen -= rc;
|
|
|
|
|
}
|
|
|
|
|
pattern = tail;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'B':
|
|
|
|
|
strcpy(output, base);
|
|
|
|
|
output += strlen(base);
|
|
|
|
|
olen -= strlen(base);
|
|
|
|
|
break;
|
|
|
|
|
|
2002-05-28 02:50:39 +02:00
|
|
|
case 'C':
|
|
|
|
|
strcpy(output, iconfig_path);
|
|
|
|
|
output += strlen(iconfig_path);
|
|
|
|
|
olen -= strlen(iconfig_path);
|
|
|
|
|
break;
|
|
|
|
|
|
2003-11-01 05:21:57 +01:00
|
|
|
case 'c':
|
|
|
|
|
strcpy(output, iconfig_common_path);
|
|
|
|
|
output += strlen(iconfig_common_path);
|
|
|
|
|
olen -= strlen(iconfig_common_path);
|
|
|
|
|
break;
|
|
|
|
|
|
2000-10-09 00:36:55 +02:00
|
|
|
case 'N':
|
|
|
|
|
if (npath) {
|
|
|
|
|
strcpy(output, npath);
|
|
|
|
|
output += strlen(npath);
|
|
|
|
|
olen -= strlen(npath);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
pattern += 1;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
*output++ = *pattern++;
|
|
|
|
|
olen -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*output = 0;
|
|
|
|
|
return output-output_save;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: build_string.c,v $
|
2003-11-13 05:09:49 +01:00
|
|
|
* Revision 1.15 2003/11/13 04:09:49 steve
|
|
|
|
|
* Pass flags through the temporary config file.
|
|
|
|
|
*
|
2003-11-01 05:21:57 +01:00
|
|
|
* Revision 1.14 2003/11/01 04:21:57 steve
|
|
|
|
|
* Add support for a target static config file.
|
|
|
|
|
*
|
2003-09-23 07:57:15 +02:00
|
|
|
* Revision 1.13 2003/09/23 05:57:15 steve
|
|
|
|
|
* Pass -m flag from driver via iconfig file.
|
|
|
|
|
*
|
2003-09-22 03:12:08 +02:00
|
|
|
* Revision 1.12 2003/09/22 01:12:09 steve
|
|
|
|
|
* Pass more ivl arguments through the iconfig file.
|
|
|
|
|
*
|
2002-08-12 03:34:58 +02:00
|
|
|
* Revision 1.11 2002/08/12 01:35:01 steve
|
|
|
|
|
* conditional ident string using autoconfig.
|
2000-10-09 00:36:55 +02:00
|
|
|
*/
|
|
|
|
|
|