diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@no-log.org> | 2018-01-10 14:35:55 +0100 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2018-01-18 13:47:20 +0000 |
commit | 780e931eed8937bd8e304449913f487fa1d056c5 (patch) | |
tree | 24446641394bdabfee26130913eed808fe658ffa /util/blobtool/blobtool.l | |
parent | 86391f16054ff1aa8af75b552204d24f3c00d50e (diff) |
util/blobtool: rename to bincfg
The name blobtool is confusing as 'blob' is also used to
describe nonfree software in binary form.
Since this utility deals with binary configurations it
makes more sense to call it bincfg.
Change-Id: I3339274f1c42df4bb4a6b30b9538d91c3c03d7d0
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
Reviewed-on: https://review.coreboot.org/23239
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Kocialkowski <contact@paulk.fr>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/blobtool/blobtool.l')
-rw-r--r-- | util/blobtool/blobtool.l | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/util/blobtool/blobtool.l b/util/blobtool/blobtool.l deleted file mode 100644 index b80cc5550d..0000000000 --- a/util/blobtool/blobtool.l +++ /dev/null @@ -1,133 +0,0 @@ -/* - * blobtool - Compiler/Decompiler for data blobs with specs - * Copyright (C) 2017 Damien Zammit <damien@zamaudio.com> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -%{ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "blobtool.tab.h" - -extern struct blob binary; - -unsigned int parsehex (char *s) -{ - unsigned int i, nib, val = 0; - unsigned int nibs = strlen(s) - 2; - - for (i = 2; i < nibs + 2; i++) { - if (s[i] >= '0' && s[i] <= '9') { - nib = s[i] - '0'; - } else if (s[i] >= 'a' && s[i] <= 'f') { - nib = s[i] - 'a' + 10; - } else if (s[i] >= 'A' && s[i] <= 'F') { - nib = s[i] - 'A' + 10; - } else { - return 0; - } - val |= nib << (((nibs - 1) - (i - 2)) * 4); - } - return val; -} - -char* stripquotes (char *string) -{ - char *stripped; - unsigned int len = strlen(string); - if (len >= 2 && string[0] == '"' && string[len - 1] == '"') { - stripped = (char *) malloc (len - 1); - if (stripped == NULL) { - printf("Out of memory\n"); - exit(1); - } - snprintf (stripped, len - 1, "%s", string + 1); - return stripped; - } - return NULL; -} - -%} - -%option noyywrap -%option nounput - -DIGIT [0-9] -INT [-]?{DIGIT}|[-]?[1-9]{DIGIT}+ -FRAC [.]{DIGIT}+ -EXP [eE][+-]?{DIGIT}+ -NUMBER {INT}|{INT}{FRAC}|{INT}{EXP}|{INT}{FRAC}{EXP} -HEX [0][x][0-9a-fA-F]+ -STRING ["][^"]*["] -COMMENT [#][^\n]*$ - -%% - -{STRING} { - yylval.str = stripquotes(yytext); - return name; -}; - -{NUMBER} { - yylval.u32 = atoi(yytext); - return val; -}; - -{HEX} { - yylval.u32 = parsehex(yytext); - return val; -}; - -\{ { - return '{'; -}; - -\} { - return '}'; -}; - -\[ { - return '['; -}; - -\] { - return ']'; -}; - -, { - return ','; -}; - -: { - return ':'; -}; - -= { - return '='; -}; - -[ \t\n]+ /* ignore whitespace */; - -{COMMENT} /* ignore comments */ - -\% { - return '%'; -}; - -<<EOF>> { return eof; }; - -%% - -void set_input_string(char* in) { - yy_scan_string(in); -} |