64 int regexScan(
char *regexStr, FILE *scanFilePtr,
char *fileName)
78 retCode = regcomp(®ex, regexStr, REG_ICASE+REG_EXTENDED);
81 fprintf(stderr,
"regex %s failed to compile\n", regexStr);
86 while (fgets(textBuff, 1024, scanFilePtr) != NULL)
89 retCode = regexec(®ex, textBuff, 1, rm, 0);
92 sprintf(msgBuff,
"%s: regex found at line %d at position %d. -> %.*s \n",
93 fileName, lineCount, rm[0].rm_so+1, rm[0].rm_eo-rm[0].rm_so, textBuff + rm[0].rm_so);
100 else if (retCode == REG_NOMATCH)
106 regerror(retCode, ®ex, msgBuff,
sizeof(msgBuff));
107 fprintf(stderr,
"Out of memory? - regex match failure: %s\n", msgBuff);
116 sprintf(msgBuff,
"%s: %s not found\n", fileName, regexStr);
132 printf(
"Usage: %s [options] [id [id ...]]\n",Name);
133 printf(
" -i :: initialize the database, then exit.\n");
134 printf(
" -c SYSCONFDIR :: FOSSology configuration directory.\n");
135 printf(
" -h :: show available command line options.\n");
136 printf(
" -v :: increase agent logging verbosity.\n");
137 printf(
" -r :: regex expression to load from command line.\n");
138 printf(
" filename :: filename to process with regex.\n");
142 int main (
int argc,
char *argv[])
144 int index, nonoptargs = 0;
159 char agent_rev[myBUFSIZ];
169 sprintf(agent_rev,
"%s.%s", VERSION, COMMIT_HASH);
171 fprintf(stdout,
"regexscan reports version info as '%s.%s'.\n", VERSION, COMMIT_HASH);
175 while((c = getopt(argc,argv,
"chir:v")) != -1)
185 sprintf(regexStr,
"%s", optarg);
200 for (index = optind; index < argc; index++)
215 printf(
"UploadPK is: %ld\n", UploadPK);
221 sprintf(fileName,
"%s", argv[optind]);
222 scanFilePtr = fopen(fileName,
"r");
225 fprintf(stderr,
"failed to open text inout file %s\n", fileName);
231 regexScan(regexStr, scanFilePtr, fileName);
Store the results of a regex match.
void Usage(char *Name)
Say how to run this program.
int regexScan(char *regexStr, FILE *scanFilePtr, char *fileName)
Regex scanner.
char * fo_scheduler_current()
Get the last read string from the scheduler.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
int agent_verbose
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level ...
PGconn * pgConn
Database connection.
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
The main FOSSology C library.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.