Used commands: perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist) perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist) perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist) perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist) perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist) Change-Id: I1008a63b804f355a916221ac994701d7584f60ff Signed-off-by: Patrick Georgi <pgeorgi@google.com> Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177 Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
		
			
				
	
	
		
			140 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			140 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: GPL-2.0-only */
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include <stdlib.h>
 | |
| #include <string.h>
 | |
| #include <ctype.h>
 | |
| #include <unistd.h>
 | |
| #include <stdint.h>
 | |
| #include "common.h"
 | |
| 
 | |
| size_t bgets(struct buffer *input, void *output, size_t len)
 | |
| {
 | |
| 	len = input->size < len ? input->size : len;
 | |
| 	memmove(output, input->data, len);
 | |
| 	input->data += len;
 | |
| 	input->size -= len;
 | |
| 	return len;
 | |
| }
 | |
| 
 | |
| size_t bputs(struct buffer *b, const void *data, size_t len)
 | |
| {
 | |
| 	memmove(&b->data[b->size], data, len);
 | |
| 	b->size += len;
 | |
| 	return len;
 | |
| }
 | |
| 
 | |
| /* The assumption in all this code is that we're given a pointer to enough data.
 | |
|  * Hence, we do not check for underflow.
 | |
|  */
 | |
| static uint8_t get8(struct buffer *input)
 | |
| {
 | |
| 	uint8_t ret = *input->data++;
 | |
| 	input->size--;
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static uint16_t get16be(struct buffer *input)
 | |
| {
 | |
| 	uint16_t ret;
 | |
| 	ret = get8(input) << 8;
 | |
| 	ret |= get8(input);
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static uint32_t get32be(struct buffer *input)
 | |
| {
 | |
| 	uint32_t ret;
 | |
| 	ret = get16be(input) << 16;
 | |
| 	ret |= get16be(input);
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static uint64_t get64be(struct buffer *input)
 | |
| {
 | |
| 	uint64_t ret;
 | |
| 	ret = get32be(input);
 | |
| 	ret <<= 32;
 | |
| 	ret |= get32be(input);
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static void put8(struct buffer *input, uint8_t val)
 | |
| {
 | |
| 	input->data[input->size] = val;
 | |
| 	input->size++;
 | |
| }
 | |
| 
 | |
| static void put16be(struct buffer *input, uint16_t val)
 | |
| {
 | |
| 	put8(input, val >> 8);
 | |
| 	put8(input, val);
 | |
| }
 | |
| 
 | |
| static void put32be(struct buffer *input, uint32_t val)
 | |
| {
 | |
| 	put16be(input, val >> 16);
 | |
| 	put16be(input, val);
 | |
| }
 | |
| 
 | |
| static void put64be(struct buffer *input, uint64_t val)
 | |
| {
 | |
| 	put32be(input, val >> 32);
 | |
| 	put32be(input, val);
 | |
| }
 | |
| 
 | |
| static uint16_t get16le(struct buffer *input)
 | |
| {
 | |
| 	uint16_t ret;
 | |
| 	ret = get8(input);
 | |
| 	ret |= get8(input) << 8;
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static uint32_t get32le(struct buffer *input)
 | |
| {
 | |
| 	uint32_t ret;
 | |
| 	ret = get16le(input);
 | |
| 	ret |= get16le(input) << 16;
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static uint64_t get64le(struct buffer *input)
 | |
| {
 | |
| 	uint64_t ret;
 | |
| 	uint32_t low;
 | |
| 	low = get32le(input);
 | |
| 	ret = get32le(input);
 | |
| 	ret <<= 32;
 | |
| 	ret |= low;
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| static void put16le(struct buffer *input, uint16_t val)
 | |
| {
 | |
| 	put8(input, val);
 | |
| 	put8(input, val >> 8);
 | |
| }
 | |
| 
 | |
| static void put32le(struct buffer *input, uint32_t val)
 | |
| {
 | |
| 	put16le(input, val);
 | |
| 	put16le(input, val >> 16);
 | |
| }
 | |
| 
 | |
| static void put64le(struct buffer *input, uint64_t val)
 | |
| {
 | |
| 	put32le(input, val);
 | |
| 	put32le(input, val >> 32);
 | |
| }
 | |
| 
 | |
| struct xdr xdr_be = {
 | |
| 	get8, get16be, get32be, get64be,
 | |
| 	put8, put16be, put32be, put64be
 | |
| };
 | |
| 
 | |
| struct xdr xdr_le = {
 | |
| 	get8, get16le, get32le, get64le,
 | |
| 	put8, put16le, put32le, put64le
 | |
| };
 |