if (UtilityBase=OpenLibrary("utility.library",37))
{
Arguments.XRefFile="autodoc.xref";
Arguments.Extension=".guide";
Arguments.ErrorFile="NIL:";
if (RDArgs=ReadArgs("AUTODOCS/A,INCLUDES/A,HYPERTEXT/A,XREFOUT/K,XREFIN/K,ERROR/K,EXTENSION/K,NOEXPAND/S,TYPES/S,CED/S,SHORTTOC/S",(long *)&Arguments,NULL))
{
if (ErrorFile=Open(Arguments.ErrorFile,MODE_NEWFILE))
{
if (AutodocDir=Lock(Arguments.AutodocDir,ACCESS_READ))
{
if (IncludeDir=Lock(Arguments.IncludeDir,ACCESS_READ))
{
if (HypertextDir=Lock(Arguments.HypertextDir,ACCESS_READ))
{
if (!ReadXRef())
{
CloseAll();
exit(RETURN_ERROR);
}
if (XRefFile=Open(Arguments.XRefFile,MODE_NEWFILE))
{
if (FPrintf(XRefFile,"/* This file was created by ADtoHT V1.3 */\n"
"/* Do not edit. */\n\n"
"XREF:\n")==-1)
{
DosError(Arguments.XRefFile);
}
printf("*** Reading includes ***\n");
if (!ProcessIncludes(IncludeDir,""))
{
CloseAll();
exit(RETURN_ERROR);
}
if (!(IncludeFileArray=(struct FileNode **)ListToArray(FileList)))
{
CloseAll();
exit(RETURN_ERROR);
}
FileList=NULL;
if (!(StructArray=(struct StructNode **)ListToArray(StructList)))
{
CloseAll();
exit(RETURN_ERROR);
}
if (!(TypedefArray=(struct StructNode **)ListToArray(TypedefList)))
{
CloseAll();
exit(RETURN_ERROR);
}
if (!PrintIncludeFileList())
{
CloseAll();
exit(RETURN_ERROR);
}
if (!PrintStructList())
{
CloseAll();
exit(RETURN_ERROR);
}
if (!PrintTypedefs())
{
CloseAll();
exit(RETURN_ERROR);
}
printf("*** Collecting autodoc contents ***\n");
if (!ReadAutodocs())
{
CloseAll();
exit(RETURN_ERROR);
}
if (!MakeShortAutodocs())
{
CloseAll();
exit(RETURN_ERROR);
}
if (!PrintShortAutodocList())
{
CloseAll();
exit(RETURN_ERROR);
}
if (FPrintf(XRefFile,"\n#\n")==-1)
{
DosError(Arguments.XRefFile);
}
printf("*** Converting autodocs to hypertext ***\n");
if (!ConvertAutodocs())
{
CloseAll();
exit(RETURN_ERROR);
}
}
else
{
DosError(Arguments.XRefFile);
}
}
else
{
DosError(Arguments.HypertextDir);
}
}
else
{
DosError(Arguments.IncludeDir);
}
}
else
{
DosError(Arguments.AutodocDir);
}
}
else
{
DosError(Arguments.ErrorFile);
}
}
else
{
DosError(NULL);
}
CloseAll();
}
else
{
Write(Output(),"ADtoHT requires Kickstart V37 or later.\n",71-32);