| 
				
			 | 
			
			
				
				@@ -2,6 +2,7 @@ 
			 | 
		
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				
				 #define _GPXE_BUFFER_H 
			 | 
		
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				
				 #include <stdint.h> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				5
			 | 
			
			
				
				+#include <errno.h> 
			 | 
		
		
	
		
			
			| 
				5
			 | 
			
				6
			 | 
			
			
				
				 #include <gpxe/uaccess.h> 
			 | 
		
		
	
		
			
			| 
				6
			 | 
			
				7
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				7
			 | 
			
				8
			 | 
			
			
				
				 /** @file 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -101,4 +102,24 @@ struct buffer { 
			 | 
		
		
	
		
			
			| 
				101
			 | 
			
				102
			 | 
			
			
				
				 extern int fill_buffer ( struct buffer *buffer, const void *data, 
			 | 
		
		
	
		
			
			| 
				102
			 | 
			
				103
			 | 
			
			
				
				 			 size_t offset, size_t len ); 
			 | 
		
		
	
		
			
			| 
				103
			 | 
			
				104
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				
				+/** Expand data buffer 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				
				+ * 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				
				+ * @v buffer		Data buffer 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				
				+ * @v new_len		New length 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				
				+ * @ret rc		Return status code 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				
				+ * 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				
				+ * Expand the data buffer to accommodate more data.  Some buffers may 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				
				+ * not support being expanded. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				
				+ */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				
				+static inline int expand_buffer ( struct buffer *buffer, size_t new_len ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				
				+	if ( new_len <= buffer->len ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				
				+		return 0; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				
				+	if ( ! buffer->expand ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				
				+		return -ENOBUFS; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				
				+	return buffer->expand ( buffer, new_len ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				
				+} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				104
			 | 
			
				125
			 | 
			
			
				
				 #endif /* _GPXE_BUFFER_H */ 
			 |