Open
Description
#include <readtags.h>
#include <stdio.h>
static void printEntry (tagEntry *entry)
{
printf ("%s,%s,%lu,%s\n", entry->name,
entry->file, entry->address.lineNumber,
entry->address.pattern);
}
int
main(int argc, char **argv)
{
char *tagfile = argv[1];
if (tagfile == NULL)
{
fprintf(stderr, "Usage: %s TAGFILE [WORD]\n", argv[0]);
return 1;
}
char *word_for_search = (argc < 2)? NULL: argv[2];
tagFileInfo tinfo;
tagFile *t = tagsOpen (tagfile, &tinfo);
if (t == NULL)
return 1;
tagResult r;
tagEntry entry;
tagResult (*next) (tagFile *const, tagEntry *const);
if (word_for_search)
{
next = tagsFindNext;
r = tagsFind (t, &entry, word_for_search, 0);
}
else
{
next = tagsNext;
r = tagsFirst (t, &entry);
}
if (r == TagSuccess)
{
do
{
printEntry (&entry);
r = (*next) (t, &entry);
}
while (r == TagSuccess);
}
tagsClose (t);
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels