FreeBSD/sys/contrib/dev/acpica/compiler/dtio.c
/******************************************************************************
 *
 * FUNCTION:    DtParseLine
 *
 * PARAMETERS:  LineBuffer          - Current source code line
 *              Line                - Current line number in the source
 *              Offset              - Current byte offset of the line
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Parse one source line
 *
 *****************************************************************************/
DtParseLine
PARAMETERS:  LineBuffer          - Current source code line
Line                - Current line number in the source
Offset              - Current byte offset of the line

Status

Parse one source line
DtParseLine PARAMETERS : LineBuffer - Current source code line Line - Current line number in the source Offset - Current byte offset of the line Status Parse one source line
static ACPI_STATUS
DtParseLine (
    char                    *LineBuffer,
    UINT32                  Line,
    UINT32                  Offset)
{
    char                    *Start;
    char                    *End;
    char                    *TmpName;
    char                    *TmpValue;
    char                    *Name;
    char                    *Value;
    char                    *Colon;
    UINT32                  Length;
    DT_FIELD                *Field;
    UINT32                  Column;
    UINT32                  NameColumn;
    BOOLEAN                 IsNullString = FALSE;
    if (!LineBuffer)
    {
        return (AE_OK);
    }
    if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER))
    {
        return (AE_NOT_FOUND);
    }
    Colon = strchr (LineBuffer, ':');
    if (!Colon)
    {
        return (AE_OK);
    }
    Start = LineBuffer;
    End = Colon;
    while (Start < Colon)
    {
        if (*Start == '[')
        {
            while (Start < Colon && *Start != ']')
            {
                Start++;
            }
        }
        else if (*Start != ' ')
        {
            break;
        }
        Start++;
    }
    Column = ACPI_PTR_DIFF (Colon, LineBuffer) + 3;
    NameColumn = ACPI_PTR_DIFF (Start, LineBuffer) + 1;
    Length = ACPI_PTR_DIFF (End, Start);
    TmpName = UtLocalCalloc (Length + 1);
    strncpy (TmpName, Start, Length);
    Name = DtTrim (TmpName);
    ACPI_FREE (TmpName);
    Start = End = (Colon + 1);
    while (*End)
    {
        if (*End == '"')
        {
            End++;
            if (*End == '"')
            {
                IsNullString = TRUE;
            }
            while (*End && (*End != '"'))
            {
                End++;
            }
            End++;
            break;
        }
        if (*End == '[')
        {
            End--;
            break;
        }
        End++;
    }
    Length = ACPI_PTR_DIFF (End, Start);
    TmpValue = UtLocalCalloc (Length + 1);
    strncpy (TmpValue, Start, Length);
    Value = DtTrim (TmpValue);
    ACPI_FREE (TmpValue);
    if ((Value && *Value) || IsNullString)
    {
        Field = UtFieldCacheCalloc ();
        Field->Name = Name;
        Field->Value = Value;
        Field->Line = Line;
        Field->ByteOffset = Offset;
        Field->NameColumn = NameColumn;
        Field->Column = Column;
        Field->StringLength = Length;
        DtLinkField (Field);
    }
    return (AE_OK);
}
static ACPI_STATUS DtParseLine ( char * LineBuffer , UINT32 Line , UINT32 Offset ) { char * Start ; char * End ; char * TmpName ; char * TmpValue ; char * Name ; char * Value ; char * Colon ; UINT32 Length ; DT_FIELD * Field ; UINT32 Column ; UINT32 NameColumn ; BOOLEAN IsNullString = FALSE ; if ( ! LineBuffer ) { return ( AE_OK ) ; } if ( strstr ( LineBuffer , ACPI_RAW_TABLE_DATA_HEADER ) ) { return ( AE_NOT_FOUND ) ; } Colon = strchr ( LineBuffer , ' ' ) ; if ( ! Colon ) { return ( AE_OK ) ; } Start = LineBuffer ; End = Colon ; while ( Start < Colon ) { if ( * Start == ' ' ) { while ( Start < Colon && * Start != ' ' ) { Start ++ ; } } else if ( * Start != ' ' ) { break ; } Start ++ ; } Column = ACPI_PTR_DIFF ( Colon , LineBuffer ) + 3 ; NameColumn = ACPI_PTR_DIFF ( Start , LineBuffer ) + 1 ; Length = ACPI_PTR_DIFF ( End , Start ) ; TmpName = UtLocalCalloc ( Length + 1 ) ; strncpy ( TmpName , Start , Length ) ; Name = DtTrim ( TmpName ) ; ACPI_FREE ( TmpName ) ; Start = End = ( Colon + 1 ) ; while ( * End ) { if ( * End == ' ' ) { End ++ ; if ( * End == ' ' ) { IsNullString = TRUE ; } while ( * End && ( * End != ' ' ) ) { End ++ ; } End ++ ; break ; } if ( * End == ' ' ) { End -- ; break ; } End ++ ; } Length = ACPI_PTR_DIFF ( End , Start ) ; TmpValue = UtLocalCalloc ( Length + 1 ) ; strncpy ( TmpValue , Start , Length ) ; Value = DtTrim ( TmpValue ) ; ACPI_FREE ( TmpValue ) ; if ( ( Value && * Value ) || IsNullString ) { Field = UtFieldCacheCalloc ( ) ; Field -> Name = Name ; Field -> Value = Value ; Field -> Line = Line ; Field -> ByteOffset = Offset ; Field -> NameColumn = NameColumn ; Field -> Column = Column ; Field -> StringLength = Length ; DtLinkField ( Field ) ; } return ( AE_OK ) ; }
FUNCTION:    DtParseLine
 PARAMETERS:  LineBuffer          - Current source code line
              Line                - Current line number in the source
              Offset              - Current byte offset of the line
FUNCTION : DtParseLine PARAMETERS : LineBuffer - Current source code line Line - Current line number in the source Offset - Current byte offset of the line
/* All lines after "Raw Table Data" are ingored */ /* Found left bracket, go to the right bracket */ /*
     * There are two column values. One for the field name,
     * and one for the field value.
     */ /* Found left quotation, go to the right quotation and break */ /* Check for an explicit null string */ /*
         * Special "comment" fields at line end, ignore them.
         * Note: normal slash-slash and slash-asterisk comments are
         * stripped already by the DtGetNextLine parser.
         *
         * TBD: Perhaps DtGetNextLine should parse the following type
         * of comments also.
         */ /* Create a new field object only if we have a valid value field */ /* Else -- Ignore this field, it has no valid data */