|  | @@ -38,19 +38,24 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
		
	
		
			
			| 38 | 38 |  struct imgsingle_options {
 | 
		
	
		
			
			| 39 | 39 |  	/** Image name */
 | 
		
	
		
			
			| 40 | 40 |  	const char *name;
 | 
		
	
		
			
			|  | 41 | +	/** Free image after execution */
 | 
		
	
		
			
			|  | 42 | +	int autofree;
 | 
		
	
		
			
			| 41 | 43 |  };
 | 
		
	
		
			
			| 42 | 44 |  
 | 
		
	
		
			
			| 43 | 45 |  /** "img{single}" option list */
 | 
		
	
		
			
			| 44 | 46 |  static struct option_descriptor imgsingle_opts[] = {
 | 
		
	
		
			
			| 45 | 47 |  	OPTION_DESC ( "name", 'n', required_argument,
 | 
		
	
		
			
			| 46 | 48 |  		      struct imgsingle_options, name, parse_string ),
 | 
		
	
		
			
			|  | 49 | +	OPTION_DESC ( "autofree", 'a', no_argument,
 | 
		
	
		
			
			|  | 50 | +		      struct imgsingle_options, autofree, parse_flag ),
 | 
		
	
		
			
			| 47 | 51 |  };
 | 
		
	
		
			
			| 48 | 52 |  
 | 
		
	
		
			
			| 49 | 53 |  /** "img{single}" command descriptor */
 | 
		
	
		
			
			| 50 | 54 |  static struct command_descriptor imgsingle_cmd =
 | 
		
	
		
			
			| 51 | 55 |  	COMMAND_DESC ( struct imgsingle_options, imgsingle_opts,
 | 
		
	
		
			
			| 52 | 56 |  		       1, MAX_ARGUMENTS,
 | 
		
	
		
			
			| 53 |  | -		       "[--name <name>] <uri|image> [<arguments>...]" );
 | 
		
	
		
			
			|  | 57 | +		       "[--name <name>] [--autofree] "
 | 
		
	
		
			
			|  | 58 | +		       "<uri|image> [<arguments>...]" );
 | 
		
	
		
			
			| 54 | 59 |  
 | 
		
	
		
			
			| 55 | 60 |  /** An "img{single}" family command descriptor */
 | 
		
	
		
			
			| 56 | 61 |  struct imgsingle_descriptor {
 | 
		
	
	
		
			
			|  | @@ -134,6 +139,10 @@ static int imgsingle_exec ( int argc, char **argv,
 | 
		
	
		
			
			| 134 | 139 |  		}
 | 
		
	
		
			
			| 135 | 140 |  	}
 | 
		
	
		
			
			| 136 | 141 |  
 | 
		
	
		
			
			|  | 142 | +	/* Set the auto-unregister flag, if applicable */
 | 
		
	
		
			
			|  | 143 | +	if ( opts.autofree )
 | 
		
	
		
			
			|  | 144 | +		image->flags |= IMAGE_AUTO_UNREGISTER;
 | 
		
	
		
			
			|  | 145 | +
 | 
		
	
		
			
			| 137 | 146 |  	/* Carry out command action, if applicable */
 | 
		
	
		
			
			| 138 | 147 |  	if ( desc->action ) {
 | 
		
	
		
			
			| 139 | 148 |  		if ( ( rc = desc->action ( image ) ) != 0 ) {
 | 
		
	
	
		
			
			|  | @@ -160,7 +169,7 @@ static int imgsingle_exec ( int argc, char **argv,
 | 
		
	
		
			
			| 160 | 169 |  static struct command_descriptor imgfetch_cmd =
 | 
		
	
		
			
			| 161 | 170 |  	COMMAND_DESC ( struct imgsingle_options, imgsingle_opts,
 | 
		
	
		
			
			| 162 | 171 |  		       1, MAX_ARGUMENTS,
 | 
		
	
		
			
			| 163 |  | -		       "[--name <name>] <uri> [<arguments>...]" );
 | 
		
	
		
			
			|  | 172 | +		       "[--name <name>] [--autofree] <uri> [<arguments>...]" );
 | 
		
	
		
			
			| 164 | 173 |  
 | 
		
	
		
			
			| 165 | 174 |  /** "imgfetch" family command descriptor */
 | 
		
	
		
			
			| 166 | 175 |  struct imgsingle_descriptor imgfetch_desc = {
 | 
		
	
	
		
			
			|  | @@ -202,7 +211,7 @@ static int imgselect_exec ( int argc, char **argv ) {
 | 
		
	
		
			
			| 202 | 211 |  static struct command_descriptor imgexec_cmd =
 | 
		
	
		
			
			| 203 | 212 |  	COMMAND_DESC ( struct imgsingle_options, imgsingle_opts,
 | 
		
	
		
			
			| 204 | 213 |  		       0, MAX_ARGUMENTS,
 | 
		
	
		
			
			| 205 |  | -		       "[--name <name>] [<uri|image> [<arguments>...]]" );
 | 
		
	
		
			
			|  | 214 | +		       "[--autofree] [<uri|image> [<arguments>...]]" );
 | 
		
	
		
			
			| 206 | 215 |  
 | 
		
	
		
			
			| 207 | 216 |  /** "imgexec" family command descriptor */
 | 
		
	
		
			
			| 208 | 217 |  struct imgsingle_descriptor imgexec_desc = {
 |