This documentation describes the Prokee module interface.
Extracts code from a directory or file.
Mark code with special comments:
///module:1
...
extracted
code here
...
///module:0
Signature:
int code_extract_run(const char *searchpath,const char *module)
Parameters:
| const char * | searchpath | [IN] | Directory or file (path) where to scan for source code. |
| const char * | module | [IN] | Name of the module. |
Return value:Returns 0 if successful, otherwise a value other than 0.
Code: toggle
int run(const char *searchpath,const char *module)
{
if(path::pathtype(searchpath) & PATH_DIR)
{
DIRECTORY *d=dir::opendir(searchpath);
char *a;
while((a=dir::getNextItem(d))[0]!=0)
{
char *b=(char *)malloc((strlen(searchpath)+strlen(a)+1)*sizeof(char));
strcpy(b,searchpath);
strcat(b,a);
run(b,module);
free(b);
}
dir::closedir(d);
}
else
{
FileReader r(searchpath);
if(r.getLastError())
{
fprintf(stderr,"[ERROR] FileReder failed to open input file. Error Code %d",r.getLastErrorDetail());
return 1;
}
char *export_filename=(char *)malloc((strlen(module)+strlen(searchpath)+10)*sizeof(char));
strcpy(export_filename,"export_");
strcat(export_filename,module);
strcat(export_filename,"/");
strcat(export_filename,searchpath);
FILE *f=file::openfile(export_filename,"wb");
if(!f)
{
fprintf(stderr,"[ERROR] Failed to open output file %s.\n",export_filename);
free(export_filename);
return 1;
}
int ch,lastch=0;
int status=0;
char *marker=(char *)malloc((strlen(module)+10)*sizeof(char));
strcpy(marker,"///");
strcat(marker,module);
strcat(marker,":");
int end_of_marker_status=strlen(marker);
bool do_export=false;
bool output_created=false;
bool is_in_comment=false;
int ocol=0;
while((ch=r.get())!=-1)
{
if(status
Runs
code_extract as if it would be called from the command-line.
This calls
code_extract_run(argv[1],argv[2]).
Signature:
int code_extract::main(int argc,char **argv)
Parameters:
| int | argc | | The number of command-line parameters. |
| char ** | argv | [IN] | The command-line parameters. |
Return value:Exit status.