Ejemplo n.º 1
0
int ACPI_SYSTEM_XFACE
main (
    int                     argc,
    char                    *argv[])
{
    int                     j;
    ACPI_CONVERSION_TABLE   *ConversionTable = NULL;
    char                    *SourcePath;
    char                    *TargetPath;
    UINT32                  FileType;


    ACPI_DEBUG_INITIALIZE (); /* For debug version only */
    AcpiOsInitialize ();
    printf (ACPI_COMMON_SIGNON (AS_UTILITY_NAME));

    if (argc < 2)
    {
        AsDisplayUsage ();
        return (0);
    }

    /* Command line options */

    while ((j = AcpiGetopt (argc, argv, AS_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j)
        {
        case 'l':

            /* Linux code generation */

            printf ("Creating Linux source code\n");
            ConversionTable = &LinuxConversionTable;
            Gbl_WidenDeclarations = TRUE;
            Gbl_IgnoreLoneLineFeeds = TRUE;
            break;

        case 'c':

            /* Cleanup code */

            printf ("Code cleanup\n");
            ConversionTable = &CleanupConversionTable;
            Gbl_Cleanup = TRUE;
            break;

        case 'h':

            /* Inject Dual-license header */

            printf ("Inserting Dual-license header to all modules\n");
            ConversionTable = &LicenseConversionTable;
            break;

        case 'i':

            /* Cleanup wrong indent result */

            printf ("Cleaning up macro indentation\n");
            ConversionTable = &IndentConversionTable;
            Gbl_IgnoreLoneLineFeeds = TRUE;
            Gbl_IgnoreTranslationEscapes = TRUE;
            break;

        case 's':

            /* Statistics only */

            break;

        case 'u':

            /* custom conversion  */

            printf ("Custom source translation\n");
            ConversionTable = &CustomConversionTable;
            break;

        case 'v':

            switch (AcpiGbl_Optarg[0])
            {
            case '^':  /* -v: (Version): signon already emitted, just exit */

                exit (0);

            case 'b':

                /* Verbose mode */

                Gbl_VerboseMode = TRUE;
                break;

            default:

                printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
                return (-1);
            }

            break;

        case 'y':

            /* Batch mode */

            Gbl_BatchMode = TRUE;
            break;

        case 'd':

            /* Leave debug statements in */

            Gbl_DebugStatementsMode = TRUE;
            break;

        case 'q':

            /* Quiet mode */

            Gbl_QuietMode = TRUE;
            break;

        default:

            AsDisplayUsage ();
            return (-1);
        }


    SourcePath = argv[AcpiGbl_Optind];
    if (!SourcePath)
    {
        printf ("Missing source path\n");
        AsDisplayUsage ();
        return (-1);
    }

    TargetPath = argv[AcpiGbl_Optind+1];

    if (!ConversionTable)
    {
        /* Just generate statistics. Ignore target path */

        TargetPath = SourcePath;

        printf ("Source code statistics only\n");
        ConversionTable = &StatsConversionTable;
    }
    else if (!TargetPath)
    {
        TargetPath = SourcePath;
    }

    if (Gbl_DebugStatementsMode)
    {
        ConversionTable->SourceFunctions &= ~CVT_REMOVE_DEBUG_MACROS;
    }

    /* Check source and target paths and files */

    if (AsExaminePaths (ConversionTable, SourcePath, TargetPath, &FileType))
    {
        return (-1);
    }

    /* Source/target can be either directories or a files */

    if (FileType == S_IFDIR)
    {
        /* Process the directory tree */

        AsProcessTree (ConversionTable, SourcePath, TargetPath);
    }
    else
    {
        /* Process a single file */

        /* Differentiate between source and header files */

        if (strstr (SourcePath, ".h"))
        {
            AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_HEADER);
        }
        else if (strstr (SourcePath, ".c"))
        {
            AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_SOURCE);
        }
        else if (strstr (SourcePath, ".patch"))
        {
            AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_PATCH);
        }
        else
        {
            printf ("Unknown file type - %s\n", SourcePath);
        }
    }

    /* Always display final summary and stats */

    AsDisplayStats ();

    return (0);
}
Ejemplo n.º 2
0
void
AsDoWildcard (
    ACPI_CONVERSION_TABLE   *ConversionTable,
    char                    *SourcePath,
    char                    *TargetPath,
    int                     MaxPathLength,
    int                     FileType,
    char                    *WildcardSpec)
{
    void                    *DirInfo;
    char                    *Filename;
    char                    *SourceDirPath;
    char                    *TargetDirPath;
    char                    RequestedFileType;


    if (FileType == FILE_TYPE_DIRECTORY)
    {
        RequestedFileType = REQUEST_DIR_ONLY;
    }
    else
    {
        RequestedFileType = REQUEST_FILE_ONLY;
    }

    VERBOSE_PRINT (("Checking for %s source files in directory \"%s\"\n",
            WildcardSpec, SourcePath));

    /* Open the directory for wildcard search */

    DirInfo = AcpiOsOpenDirectory (SourcePath, WildcardSpec, RequestedFileType);
    if (DirInfo)
    {
        /*
         * Get all of the files that match both the
         * wildcard and the requested file type
         */
        while ((Filename = AcpiOsGetNextFilename (DirInfo)))
        {
            /* Looking for directory files, must check file type */

            switch (RequestedFileType)
            {
            case REQUEST_DIR_ONLY:

                /* If we actually have a dir, process the subtree */

                if (!AsCheckForDirectory (SourcePath, TargetPath, Filename,
                        &SourceDirPath, &TargetDirPath))
                {
                    VERBOSE_PRINT (("Subdirectory: %s\n", Filename));

                    AsProcessTree (ConversionTable, SourceDirPath, TargetDirPath);
                    free (SourceDirPath);
                    free (TargetDirPath);
                }
                break;

            case REQUEST_FILE_ONLY:

                /* Otherwise, this is a file, not a directory */

                VERBOSE_PRINT (("File: %s\n", Filename));

                AsProcessOneFile (ConversionTable, SourcePath, TargetPath,
                        MaxPathLength, Filename, FileType);
                break;

            default:

                break;
            }
        }

        /* Cleanup */

        AcpiOsCloseDirectory (DirInfo);
    }
}
Ejemplo n.º 3
0
int ACPI_SYSTEM_XFACE
main (
    int                     argc,
    char                    *argv[])
{
    int                     j;
    ACPI_CONVERSION_TABLE   *ConversionTable = NULL;
    char                    *SourcePath;
    char                    *TargetPath;
    UINT32                  FileType;


    printf (ACPI_COMMON_SIGNON ("ACPI Source Code Conversion Utility"));

    if (argc < 2)
    {
        AsDisplayUsage ();
        return 0;
    }

    /* Command line options */

    while ((j = AcpiGetopt (argc, argv, "cdhlqsuvy")) != EOF) switch(j)
        {
        case 'l':
            /* Linux code generation */

            printf ("Creating Linux source code\n");
            ConversionTable = &LinuxConversionTable;
            Gbl_WidenDeclarations = TRUE;
            Gbl_IgnoreLoneLineFeeds = TRUE;
            break;

        case 'c':
            /* Cleanup code */

            printf ("Code cleanup\n");
            ConversionTable = &CleanupConversionTable;
            break;

        case 'h':
            /* Inject Dual-license header */

            printf ("Inserting Dual-license header to all modules\n");
            ConversionTable = &LicenseConversionTable;
            break;

        case 's':
            /* Statistics only */

            break;

        case 'u':
            /* custom conversion  */

            printf ("Custom source translation\n");
            ConversionTable = &CustomConversionTable;
            break;

        case 'v':
            /* Verbose mode */

            Gbl_VerboseMode = TRUE;
            break;

        case 'y':
            /* Batch mode */

            Gbl_BatchMode = TRUE;
            break;

        case 'd':
            /* Leave debug statements in */

            Gbl_DebugStatementsMode = TRUE;
            break;

        case 'q':
            /* Quiet mode */

            Gbl_QuietMode = TRUE;
            break;

        default:
            AsDisplayUsage ();
            return -1;
        }


    SourcePath = argv[AcpiGbl_Optind];
    if (!SourcePath)
    {
        printf ("Missing source path\n");
        AsDisplayUsage ();
        return -1;
    }

    TargetPath = argv[AcpiGbl_Optind+1];

    if (!ConversionTable)
    {
        /* Just generate statistics.  Ignore target path */

        TargetPath = SourcePath;

        printf ("Source code statistics only\n");
        ConversionTable = &StatsConversionTable;
    }
    else if (!TargetPath)
    {
        TargetPath = SourcePath;
    }

    if (Gbl_DebugStatementsMode)
    {
        ConversionTable->SourceFunctions &= ~CVT_REMOVE_DEBUG_MACROS;
    }

    /* Check source and target paths and files */

    if (AsExaminePaths (ConversionTable, SourcePath, TargetPath, &FileType))
    {
        return -1;
    }

    /* Source/target can be either directories or a files */

    if (FileType == S_IFDIR)
    {
        /* Process the directory tree */

        AsProcessTree (ConversionTable, SourcePath, TargetPath);
    }
    else
    {
        /* Process a single file */

        /* Differentiate between source and header files */

        if (strstr (SourcePath, ".h"))
        {
            AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_HEADER);
        }
        else
        {
            AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_SOURCE);
        }
    }

    /* Always display final summary and stats */

    AsDisplayStats ();

    return 0;
}