本文整理汇总了C++中astring::cstr方法的典型用法代码示例。如果您正苦于以下问题:C++ astring::cstr方法的具体用法?C++ astring::cstr怎么用?C++ astring::cstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astring
的用法示例。
在下文中一共展示了astring::cstr方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &path)
{
astring modified(templatefile);
modified.replace(0, "<!--PATH-->", path.cstr());
core_fwrite(file, modified.cstr(), modified.len());
core_fclose(file);
}
示例2: machine_reset
void ldplayer_state::machine_reset()
{
// set up a timer to start playing immediately
timer_set(attotime::zero, TIMER_ID_AUTOPLAY);
// indicate the name of the file we opened
popmessage("Opened %s\n", m_filename.cstr());
}
示例3: assemble_arguments_from_W_table
void assemble_arguments_from_W_table(UINT16 W, char ma, const astring& SD, const astring& ea,
astring& source, astring& destination)
{
char temp[32];
sprintf(temp, "%c:%s", ma, ea.cstr());
switch(W)
{
case 0x0: source = SD; destination = temp; break;
case 0x1: source = temp; destination = SD; break;
}
}
示例4: handle_missing_file
static void handle_missing_file(romload_private *romdata, const rom_entry *romp, astring tried_file_names, chd_error chderr)
{
if(tried_file_names.len() != 0)
tried_file_names = " (tried in " + tried_file_names + ")";
astring name(ROM_GETNAME(romp));
bool is_chd = (chderr != CHDERR_NONE);
if (is_chd)
name += ".chd";
bool is_chd_error = (is_chd && chderr != CHDERR_FILE_NOT_FOUND);
if (is_chd_error)
romdata->errorstring.catprintf("%s CHD ERROR: %s\n", name.cstr(), chd_file::error_string(chderr));
/* optional files are okay */
if (ROM_ISOPTIONAL(romp))
{
if (!is_chd_error)
romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND%s\n", name.cstr(), tried_file_names.cstr());
romdata->warnings++;
}
/* no good dumps are okay */
else if (hash_collection(ROM_GETHASHDATA(romp)).flag(hash_collection::FLAG_NO_DUMP))
{
if (!is_chd_error)
romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.cstr(), tried_file_names.cstr());
romdata->knownbad++;
}
/* anything else is bad */
else
{
if (!is_chd_error)
romdata->errorstring.catprintf("%s NOT FOUND%s\n", name.cstr(), tried_file_names.cstr());
romdata->errors++;
}
}
示例5: output_file
static int output_file(file_type type, int srcrootlen, int dstrootlen, astring &srcfile, astring &dstfile, bool link_to_file, astring &tempheader, astring &tempfooter)
{
// extract a normalized subpath
astring srcfile_subpath;
normalized_subpath(srcfile_subpath, srcfile, srcrootlen + 1);
fprintf(stderr, "Processing %s\n", srcfile_subpath.cstr());
// set some defaults
bool color_quotes = false;
const char *comment_start = "";
const char *comment_start_esc = "";
const char *comment_end = "";
const char *comment_end_esc = "";
const char *comment_inline = "";
const char *comment_inline_esc = "";
const char *token_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#";
const token_entry *token_table = dummy_token_table;
// based on the file type, set the comment info
switch (type)
{
case FILE_TYPE_C:
color_quotes = true;
comment_start = comment_start_esc = "/*";
comment_end = comment_end_esc = "*/";
comment_inline = comment_inline_esc = "//";
token_table = c_token_table;
break;
case FILE_TYPE_MAKE:
color_quotes = true;
comment_inline = comment_inline_esc = "#";
break;
case FILE_TYPE_XML:
color_quotes = true;
comment_start = "<!--";
comment_start_esc = "<!--";
comment_end = "-->";
comment_end_esc = "-->";
break;
default:
case FILE_TYPE_TEXT:
break;
}
// make the token lookup table
bool is_token[256];
memset(is_token, 0, sizeof(is_token));
for (int toknum = 0; token_chars[toknum] != 0; toknum++)
is_token[(UINT8)token_chars[toknum]] = true;
// open the source file
core_file *src;
if (core_fopen(srcfile, OPEN_FLAG_READ, &src) != FILERR_NONE)
{
fprintf(stderr, "Unable to read file '%s'\n", srcfile.cstr());
return 1;
}
// open the output file
core_file *dst = create_file_and_output_header(dstfile, tempheader, srcfile_subpath);
if (dst == NULL)
{
fprintf(stderr, "Unable to write file '%s'\n", dstfile.cstr());
core_fclose(src);
return 1;
}
// output the directory navigation
core_fprintf(dst, "<h3>Viewing File: ");
output_path_as_links(dst, srcfile_subpath, false, link_to_file);
core_fprintf(dst, "</h3>");
// start with some tags
core_fprintf(dst, "\t<pre class=\"source\">\n");
// iterate over lines in the source file
int linenum = 1;
bool in_comment = false;
char srcline[4096];
while (core_fgets(srcline, ARRAY_LENGTH(srcline), src) != NULL)
{
// start with the line number
astring dstline;
dstline.catprintf("<span class=\"linenum\">%5d</span> ", linenum++);
// iterate over characters in the source line
bool escape = false;
bool in_quotes = false;
bool in_inline_comment = false;
bool last_token_was_include = false;
bool last_was_token = false;
bool quotes_are_linked = false;
UINT8 curquote = 0;
int curcol = 0;
for (char *srcptr = srcline; *srcptr != 0; )
{
//.........这里部分代码省略.........
示例6: recurse_dir
static int recurse_dir(int srcrootlen, int dstrootlen, astring &srcdir, astring &dstdir, astring &tempheader, astring &tempfooter)
{
static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
// extract a normalized subpath
astring srcdir_subpath;
normalized_subpath(srcdir_subpath, srcdir, srcrootlen + 1);
// create an index file
astring indexname;
indexname.printf("%s%c%s", dstdir.cstr(), PATH_SEPARATOR[0], "index.html");
core_file *indexfile = create_file_and_output_header(indexname, tempheader, srcdir_subpath);
// output the directory navigation
core_fprintf(indexfile, "<h3>Viewing Directory: ");
output_path_as_links(indexfile, srcdir_subpath, true, false);
core_fprintf(indexfile, "</h3>");
// iterate first over directories, then over files
int result = 0;
for (int entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
{
osd_dir_entry_type entry_type = typelist[entindex];
// open the directory and iterate through it
osd_directory *dir = osd_opendir(srcdir);
if (dir == NULL)
{
result = 1;
break;
}
// build up the list of files
const osd_directory_entry *entry;
int found = 0;
list_entry *list = NULL;
while ((entry = osd_readdir(dir)) != NULL)
if (entry->type == entry_type && entry->name[0] != '.')
{
list_entry *lentry = new list_entry;
lentry->name.cpy(entry->name);
lentry->next = list;
list = lentry;
found++;
}
// close the directory
osd_closedir(dir);
// skip if nothing found
if (found == 0)
continue;
// allocate memory for sorting
list_entry **listarray = new list_entry *[found];
found = 0;
for (list_entry *curlist = list; curlist != NULL; curlist = curlist->next)
listarray[found++] = curlist;
// sort the list
qsort(listarray, found, sizeof(listarray[0]), compare_list_entries);
// rebuild the list
list = NULL;
while (--found >= 0)
{
listarray[found]->next = list;
list = listarray[found];
}
delete[] listarray;
// iterate through each file
for (list_entry *curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
{
// add a header
if (curlist == list)
core_fprintf(indexfile, "\t<h2>%s</h2>\n\t<ul>\n", (entry_type == ENTTYPE_DIR) ? "Directories" : "Files");
// build the source filename
astring srcfile;
srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
// if we have a file, output it
astring dstfile;
if (entry_type == ENTTYPE_FILE)
{
// make sure we care, first
file_type type = FILE_TYPE_INVALID;
for (int extnum = 0; extnum < ARRAY_LENGTH(extension_lookup); extnum++)
if (core_filename_ends_with(curlist->name, extension_lookup[extnum].extension))
{
type = extension_lookup[extnum].type;
break;
}
// if we got a valid file, process it
if (type != FILE_TYPE_INVALID)
{
dstfile.printf("%s%c%s.html", dstdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
if (indexfile != NULL)
//.........这里部分代码省略.........
示例7: generate_png_diff
static int generate_png_diff(const astring& imgfile1, const astring& imgfile2, const astring& outfilename)
{
bitmap_argb32 bitmap1;
bitmap_argb32 bitmap2;
bitmap_argb32 finalbitmap;
int width, height, maxwidth;
core_file *file = NULL;
file_error filerr;
png_error pngerr;
int error = 100;
bool bitmaps_differ;
int x, y;
/* open the source image */
filerr = core_fopen(imgfile1, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
{
printf("Could not open %s (%d)\n", imgfile1.cstr(), filerr);
goto error;
}
/* load the source image */
pngerr = png_read_bitmap(file, bitmap1);
core_fclose(file);
if (pngerr != PNGERR_NONE)
{
printf("Could not read %s (%d)\n", imgfile1.cstr(), pngerr);
goto error;
}
/* open the source image */
filerr = core_fopen(imgfile2, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
{
printf("Could not open %s (%d)\n", imgfile2.cstr(), filerr);
goto error;
}
/* load the source image */
pngerr = png_read_bitmap(file, bitmap2);
core_fclose(file);
if (pngerr != PNGERR_NONE)
{
printf("Could not read %s (%d)\n", imgfile2.cstr(), pngerr);
goto error;
}
/* if the sizes are different, we differ; otherwise start off assuming we are the same */
bitmaps_differ = (bitmap2.width() != bitmap1.width() || bitmap2.height() != bitmap1.height());
/* compare scanline by scanline */
for (y = 0; y < bitmap2.height() && !bitmaps_differ; y++)
{
UINT32 *base = &bitmap1.pix32(y);
UINT32 *curr = &bitmap2.pix32(y);
/* scan the scanline */
for (x = 0; x < bitmap2.width(); x++)
if (*base++ != *curr++)
break;
bitmaps_differ = (x != bitmap2.width());
}
if (bitmaps_differ)
{
/* determine the size of the final bitmap */
height = width = 0;
{
/* determine the maximal width */
maxwidth = MAX(bitmap1.width(), bitmap2.width());
width = bitmap1.width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE + maxwidth;
/* add to the height */
height += MAX(bitmap1.height(), bitmap2.height());
}
/* allocate the final bitmap */
finalbitmap.allocate(width, height);
/* now copy and compare each set of bitmaps */
int curheight = MAX(bitmap1.height(), bitmap2.height());
/* iterate over rows in these bitmaps */
for (y = 0; y < curheight; y++)
{
UINT32 *src1 = (y < bitmap1.height()) ? &bitmap1.pix32(y) : NULL;
UINT32 *src2 = (y < bitmap2.height()) ? &bitmap2.pix32(y) : NULL;
UINT32 *dst1 = &finalbitmap.pix32(y);
UINT32 *dst2 = &finalbitmap.pix32(y, bitmap1.width() + BITMAP_SPACE);
UINT32 *dstdiff = &finalbitmap.pix32(y, bitmap1.width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE);
/* now iterate over columns */
for (x = 0; x < maxwidth; x++)
{
int pix1 = -1, pix2 = -2;
if (src1 != NULL && x < bitmap1.width())
pix1 = dst1[x] = src1[x];
if (src2 != NULL && x < bitmap2.width())
pix2 = dst2[x] = src2[x];
dstdiff[x] = (pix1 != pix2) ? 0xffffffff : 0xff000000;
//.........这里部分代码省略.........
示例8: recurse_dir
static int recurse_dir(int srcrootlen, astring &srcdir)
{
static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
int result = 0;
// iterate first over directories, then over files
for (int entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
{
osd_dir_entry_type entry_type = typelist[entindex];
// open the directory and iterate through it
osd_directory *dir = osd_opendir(srcdir);
if (dir == NULL)
{
result = 1;
goto error;
}
// build up the list of files
const osd_directory_entry *entry;
list_entry *list = NULL;
int found = 0;
while ((entry = osd_readdir(dir)) != NULL)
if (entry->type == entry_type && entry->name[0] != '.')
{
list_entry *lentry = new list_entry;
lentry->name.cpy(entry->name);
lentry->next = list;
list = lentry;
found++;
}
// close the directory
osd_closedir(dir);
// skip if nothing found
if (found == 0)
continue;
// allocate memory for sorting
list_entry **listarray = new list_entry *[found];
found = 0;
for (list_entry *curlist = list; curlist != NULL; curlist = curlist->next)
listarray[found++] = curlist;
// sort the list
qsort(listarray, found, sizeof(listarray[0]), compare_list_entries);
// rebuild the list
list = NULL;
while (--found >= 0)
{
listarray[found]->next = list;
list = listarray[found];
}
delete[] listarray;
// iterate through each file
for (list_entry *curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
{
astring srcfile;
// build the source filename
srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
// if we have a file, output it
if (entry_type == ENTTYPE_FILE)
{
// make sure we care, first
if (core_filename_ends_with(curlist->name, ".c"))
{
dependency_map depend_map;
// find dependencies
file_entry &file = compute_dependencies(srcrootlen, srcfile);
recurse_dependencies(file, depend_map);
// convert the target from source to object (makes assumptions about rules)
astring target(file.name);
target.replace(0, "src/", "$(OBJ)/");
target.replace(0, ".c", ".o");
printf("\n%s : \\\n", target.cstr());
// iterate over the hashed dependencies and output them as well
for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
printf("\t%s \\\n", entry->tag().cstr());
}
}
// if we have a directory, recurse
else
result = recurse_dir(srcrootlen, srcfile);
}
// free all the allocated entries
while (list != NULL)
{
list_entry *next = list->next;
delete list;
list = next;
//.........这里部分代码省略.........
示例9: create_linked_file
static void create_linked_file(astring &dirname, const summary_file *curfile, const summary_file *prevfile, const summary_file *nextfile, const char *pngfile, astring &tempheader, astring &tempfooter)
{
astring linkname;
astring filename;
astring title;
core_file *linkfile;
int listnum;
/* create the filename */
filename.printf("%s.html", curfile->name);
/* output header */
title.printf("%s Regressions (%s)", curfile->name, curfile->source);
linkname.printf("%s" PATH_SEPARATOR "%s", dirname.cstr(), filename.cstr());
linkfile = create_file_and_output_header(linkname, tempheader, title);
if (linkfile == NULL)
{
fprintf(stderr, "Error creating file '%s'\n", filename.cstr());
return;
}
/* link to the previous/next entries */
core_fprintf(linkfile, "\t<p>\n");
core_fprintf(linkfile, "\t<table width=\"100%%\">\n");
core_fprintf(linkfile, "\t\t<td align=\"left\" width=\"40%%\" style=\"border:none\">");
if (prevfile != NULL)
core_fprintf(linkfile, "<a href=\"%s.html\"><< %s (%s)</a>", prevfile->name, prevfile->name, prevfile->source);
core_fprintf(linkfile, "</td>\n");
core_fprintf(linkfile, "\t\t<td align=\"center\" width=\"20%%\" style=\"border:none\"><a href=\"index.html\">Home</a></td>\n");
core_fprintf(linkfile, "\t\t<td align=\"right\" width=\"40%%\" style=\"border:none\">");
if (nextfile != NULL)
core_fprintf(linkfile, "<a href=\"%s.html\">%s (%s) >></a>", nextfile->name, nextfile->name, nextfile->source);
core_fprintf(linkfile, "</td>\n");
core_fprintf(linkfile, "\t</table>\n");
core_fprintf(linkfile, "\t</p>\n");
/* output data for each one */
for (listnum = 0; listnum < list_count; listnum++)
{
int imageindex = -1;
/* generate the HTML */
core_fprintf(linkfile, "\n\t<h2>%s</h2>\n", lists[listnum].version);
core_fprintf(linkfile, "\t<p>\n");
core_fprintf(linkfile, "\t<b>Status:</b> %s\n", status_text[curfile->status[listnum]]);
if (pngfile != NULL)
imageindex = get_unique_index(curfile, listnum);
if (imageindex != -1)
core_fprintf(linkfile, " [%d]", imageindex);
core_fprintf(linkfile, "\t</p>\n");
if (curfile->text[listnum].len() != 0)
{
core_fprintf(linkfile, "\t<p>\n");
core_fprintf(linkfile, "\t<b>Errors:</b>\n");
core_fprintf(linkfile, "\t<pre>%s</pre>\n", curfile->text[listnum].cstr());
core_fprintf(linkfile, "\t</p>\n");
}
}
/* output link to the image */
if (pngfile != NULL)
{
core_fprintf(linkfile, "\n\t<h2>Screenshot Comparisons</h2>\n");
core_fprintf(linkfile, "\t<p>\n");
core_fprintf(linkfile, "\t<img src=\"%s\" />\n", pngfile);
core_fprintf(linkfile, "\t</p>\n");
}
/* output footer */
output_footer_and_close_file(linkfile, tempfooter, title);
}
示例10: generate_png_diff
static int generate_png_diff(const summary_file *curfile, astring &destdir, const char *destname)
{
bitmap_argb32 bitmaps[MAX_COMPARES];
astring srcimgname;
astring dstfilename;
astring tempname;
bitmap_argb32 finalbitmap;
int width, height, maxwidth;
int bitmapcount = 0;
int listnum, bmnum;
core_file *file = NULL;
file_error filerr;
png_error pngerr;
int error = -1;
int starty;
/* generate the common source filename */
dstfilename.printf("%s" PATH_SEPARATOR "%s", destdir.cstr(), destname);
srcimgname.printf("snap" PATH_SEPARATOR "%s" PATH_SEPARATOR "final.png", curfile->name);
/* open and load all unique bitmaps */
for (listnum = 0; listnum < list_count; listnum++)
if (curfile->matchbitmap[listnum] == listnum)
{
tempname.printf("%s" PATH_SEPARATOR "%s", lists[listnum].dir, srcimgname.cstr());
/* open the source image */
filerr = core_fopen(tempname, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
goto error;
/* load the source image */
pngerr = png_read_bitmap(file, bitmaps[bitmapcount++]);
core_fclose(file);
if (pngerr != PNGERR_NONE)
goto error;
}
/* if there's only one unique bitmap, skip it */
if (bitmapcount <= 1)
goto error;
/* determine the size of the final bitmap */
height = width = 0;
maxwidth = bitmaps[0].width();
for (bmnum = 1; bmnum < bitmapcount; bmnum++)
{
int curwidth;
/* determine the maximal width */
maxwidth = MAX(maxwidth, bitmaps[bmnum].width());
curwidth = bitmaps[0].width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE + maxwidth;
width = MAX(width, curwidth);
/* add to the height */
height += MAX(bitmaps[0].height(), bitmaps[bmnum].height());
if (bmnum != 1)
height += BITMAP_SPACE;
}
/* allocate the final bitmap */
finalbitmap.allocate(width, height);
/* now copy and compare each set of bitmaps */
starty = 0;
for (bmnum = 1; bmnum < bitmapcount; bmnum++)
{
bitmap_argb32 &bitmap1 = bitmaps[0];
bitmap_argb32 &bitmap2 = bitmaps[bmnum];
int curheight = MAX(bitmap1.height(), bitmap2.height());
int x, y;
/* iterate over rows in these bitmaps */
for (y = 0; y < curheight; y++)
{
UINT32 *src1 = (y < bitmap1.height()) ? &bitmap1.pix32(y) : NULL;
UINT32 *src2 = (y < bitmap2.height()) ? &bitmap2.pix32(y) : NULL;
UINT32 *dst1 = &finalbitmap.pix32(starty + y, 0);
UINT32 *dst2 = &finalbitmap.pix32(starty + y, bitmap1.width() + BITMAP_SPACE);
UINT32 *dstdiff = &finalbitmap.pix32(starty + y, bitmap1.width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE);
/* now iterate over columns */
for (x = 0; x < maxwidth; x++)
{
int pix1 = -1, pix2 = -2;
if (src1 != NULL && x < bitmap1.width())
pix1 = dst1[x] = src1[x];
if (src2 != NULL && x < bitmap2.width())
pix2 = dst2[x] = src2[x];
dstdiff[x] = (pix1 != pix2) ? 0xffffffff : 0xff000000;
}
}
/* update the starting Y position */
starty += BITMAP_SPACE + MAX(bitmap1.height(), bitmap2.height());
}
/* write the final PNG */
filerr = core_fopen(dstfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
//.........这里部分代码省略.........
示例11: output_report
static void output_report(astring &dirname, astring &tempheader, astring &tempfooter, summary_file *filelist)
{
summary_file *buckethead[BUCKET_COUNT], **buckettailptr[BUCKET_COUNT];
summary_file *curfile;
astring title("MAME Regressions");
astring tempname;
int listnum, bucknum;
core_file *indexfile;
int count = 0, total;
/* initialize the lists */
for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++)
{
buckethead[bucknum] = NULL;
buckettailptr[bucknum] = &buckethead[bucknum];
}
/* compute the total number of files */
total = 0;
for (curfile = filelist; curfile != NULL; curfile = curfile->next)
total++;
/* first bucketize the games */
for (curfile = filelist; curfile != NULL; curfile = curfile->next)
{
int statcount[STATUS_COUNT] = { 0 };
int bucket = BUCKET_UNKNOWN;
int unique_codes = 0;
int first_valid;
/* print status */
if (++count % 100 == 0)
fprintf(stderr, "Processing file %d/%d\n", count, total);
/* find the first valid entry */
for (first_valid = 0; curfile->status[first_valid] == STATUS_NOT_PRESENT; first_valid++) ;
/* do we need to output anything? */
for (listnum = first_valid; listnum < list_count; listnum++)
if (statcount[curfile->status[listnum]]++ == 0)
unique_codes++;
/* were we consistent? */
if (unique_codes == 1)
{
/* were we consistently ok? */
if (curfile->status[first_valid] == STATUS_SUCCESS)
bucket = compare_screenshots(curfile);
/* must have been consistently erroring */
else
bucket = BUCKET_CONSISTENT_ERROR;
}
/* ok, we're not consistent; could be a number of things */
else
{
/* were we ok at the start and end but not in the middle? */
if (curfile->status[first_valid] == STATUS_SUCCESS && curfile->status[list_count - 1] == STATUS_SUCCESS)
bucket = BUCKET_GOOD_BUT_CHANGED;
/* did we go from good to bad? */
else if (curfile->status[first_valid] == STATUS_SUCCESS)
bucket = BUCKET_REGRESSED;
/* did we go from bad to good? */
else if (curfile->status[list_count - 1] == STATUS_SUCCESS)
bucket = BUCKET_IMPROVED;
/* must have had multiple errors */
else
bucket = BUCKET_MULTI_ERROR;
}
/* add us to the appropriate list */
*buckettailptr[bucket] = curfile;
buckettailptr[bucket] = &curfile->next;
}
/* terminate all the lists */
for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++)
*buckettailptr[bucknum] = NULL;
/* output header */
tempname.printf("%s" PATH_SEPARATOR "%s", dirname.cstr(), "index.html");
indexfile = create_file_and_output_header(tempname, tempheader, title);
if (indexfile == NULL)
{
fprintf(stderr, "Error creating file '%s'\n", tempname.cstr());
return;
}
/* iterate over buckets and output them */
for (bucknum = 0; bucknum < ARRAY_LENGTH(bucket_output_order); bucknum++)
{
int curbucket = bucket_output_order[bucknum];
if (buckethead[curbucket] != NULL)
{
fprintf(stderr, "Outputting bucket: %s\n", bucket_name[curbucket]);
//.........这里部分代码省略.........
示例12: recurse_dir
static int recurse_dir(astring &srcdir)
{
int result = 0;
// iterate through each file
for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)
{
for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)
{
astring srcfile;
// build the source filename
srcfile.printf("%s%s.c", srcdir.cstr(), src->name.cstr());
dependency_map depend_map;
// find dependencies
file_entry &file = compute_dependencies(srcfile);
recurse_dependencies(file, depend_map);
for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
{
astring t(entry->tag());
if (core_filename_ends_with(t, ".h"))
{
char *foundfile = include_map.find(t);
if (foundfile != NULL) {
printf("%s\n", foundfile);
// we add things just once when needed
include_map.remove(t);
}
}
}
}
}
// iterate through each file
for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)
{
// convert the target from source to object (makes assumptions about rules)
astring target("$(OBJ)/target/",lib->name.cstr());
target.cat(".a");
printf("\n%s : \\\n", target.cstr());
for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)
{
astring srcfile;
// build the source filename
srcfile.printf("%s%s.c", srcdir.cstr(), src->name.cstr());
dependency_map depend_map;
// find dependencies
file_entry &file = compute_dependencies(srcfile);
recurse_dependencies(file, depend_map);
// iterate over the hashed dependencies and output them as well
for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
{
astring t(entry->tag());
t.replace(0, "src/", "$(OBJ)/");
t.replace(0, ".c", ".o");
if (core_filename_ends_with(t, ".o"))
{
printf("\t%s \\\n", t.cstr());
}
}
}
printf("\n");
for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)
{
astring srcfile;
// build the source filename
srcfile.printf("%s%s.c", srcdir.cstr(), src->name.cstr());
dependency_map depend_map;
// find dependencies
file_entry &file = compute_dependencies(srcfile);
recurse_dependencies(file, depend_map);
for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
{
astring t(entry->tag());
if (core_filename_ends_with(t, ".lay"))
{
astring target2(file.name);
target2.replace(0, "src/", "$(OBJ)/");
target2.replace(0, ".c", ".o");
t.replace(0, "src/", "$(OBJ)/");
t.replace(0, ".lay", ".lh");
printf("%s: %s\n", target2.cstr(), t.cstr());
}
if (core_filename_ends_with(t, ".inc"))
{
astring target2(file.name);
target2.replace(0, "src/", "$(OBJ)/");
target2.replace(0, ".c", ".o");
//.........这里部分代码省略.........