iohelpers: input reader, out_bin
This commit is contained in:
		
							parent
							
								
									e854671d5f
								
							
						
					
					
						commit
						cddfdba1a7
					
				|  | @ -252,7 +252,7 @@ int action_export (bool armor, | |||
| 		data = envelope_format (ENVELOPE_PUBKEYS, parts, r); | ||||
| 	} | ||||
| 
 | ||||
| 	out (data); | ||||
| 	out_bin (data); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -408,7 +408,7 @@ int action_export_sec (bool armor, | |||
| 		data = envelope_format (ENVELOPE_SECRETS, parts, r); | ||||
| 	} | ||||
| 
 | ||||
| 	out (data); | ||||
| 	out_bin (data); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
|  |  | |||
|  | @ -35,3 +35,18 @@ bool redirect_cout (const std::string& fn) | |||
| 	std::cout.rdbuf (alt_cout.rdbuf() ); | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| #define bufsize 1024 | ||||
| bool read_all_input (std::string&data) | ||||
| { | ||||
| 	data.clear(); | ||||
| 	char buf[bufsize]; | ||||
| 	for (;;) { | ||||
| 		std::cin.read (buf, bufsize); | ||||
| 		if (std::cin) data.append (buf, bufsize); | ||||
| 		else if (std::cin.eof() ) { | ||||
| 			data.append (buf, std::cin.gcount() ); | ||||
| 			return true; | ||||
| 		} else return false; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ | |||
| #include <string> | ||||
| 
 | ||||
| #define out(x) std::cout << x << std::endl | ||||
| #define out_bin(x) std::cout << x | ||||
| #define outeol std::cout << std::endl | ||||
| #define err(x) std::cerr << x << std::endl | ||||
| #define erreol std::cerr << std::endl | ||||
|  | @ -40,4 +41,6 @@ | |||
| bool redirect_cin (const std::string& fn); | ||||
| bool redirect_cout (const std::string& fn); | ||||
| 
 | ||||
| bool read_all_input (std::string&); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue