Beispiel #1
0
/*--------------------------------------------------------------------------------------------------
  Take the relative path, and return the full path.
--------------------------------------------------------------------------------------------------*/
char *utFullPath(
    char *relativePath)
{ 
    char *fileName = relativePath;
    char *dirName = utGetcwd();

    if(*relativePath == UTDIRSEP || (*relativePath != '\0' && relativePath[1] == ':')) {
        return utCopyString(relativePath);
    }
    if(fileName == NULL) {
        return utSprintf("%s%c%s", dirName, UTDIRSEP, relativePath);
    }
    while(!strncmp(fileName, ".." UTDIRSEP_STRING, 3)) {
        fileName = fileName + 3;
        dirName = utDirName(dirName);
        if(dirName == NULL) {
            return utSprintf("%s%c%s", dirName, UTDIRSEP, relativePath);
        }
    }
    return utSprintf("%s%c%s", dirName, UTDIRSEP, fileName);
}
Beispiel #2
0
// Main entry point.  Process parameters and call the generators.
int main(
    int argc,
    char *argv[])
{
    char *exeName;

    if(argc != 3) {
        fprintf(stderr, "Usage: %s prefix commandFile\n", argv[0]);
        return 1;
    }
    utStart();
    exeName = utReplaceSuffix(utBaseName(argv[0]), "");
    utInitLogFile(utSprintf("%s.log", exeName));
    coDatabaseStart();
    coTheRoot = coRootAlloc();
    coParseCommandFile(argv[2]);
    coPreprocessDataTypes();
    coGenerateCommandParser(argv[2], argv[1]);
    coDatabaseStop();
    utStop(false);
    return 0;
}
Beispiel #3
0
/*--------------------------------------------------------------------------------------------------
  Set the environment variable.
--------------------------------------------------------------------------------------------------*/
void utSetEnvironmentVariable(
    char *name,
    char *value)
{
    putenv(utSprintf("%s=%s", name, value));
}