-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgnucap.cc
More file actions
51 lines (34 loc) · 1.03 KB
/
gnucap.cc
File metadata and controls
51 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "gnucap.h"
#include "gnucap/u_lang.h"
#include "gnucap/c_comand.h"
#include "gnucap/globals.h"
#include "gnucap/m_wave.h"
#include "gnucap/s__.h"
#include "gnucap/io_.h"
#include "numpy_interface.h"
#include <stdio.h>
#include <string>
#include <fstream>
std::string command(char *command) {
char filename[L_tmpnam];
tmpnam(filename);
// supress output to stdout
IO::mstdout.detach(stdout);
// send output to file
CMD::command(std::string("> ") + std::string(filename), &CARD_LIST::card_list);
CMD::command(std::string(command), &CARD_LIST::card_list);
CMD::command(">", &CARD_LIST::card_list);
// Open file an read it
std::ifstream ifs(filename);
std::ostringstream oss;
oss << ifs.rdbuf();
std::string output(oss.str());
unlink(filename);
return output;
}
DISPATCHER<CMD>::INSTALL *attach_command(char *command_name, CMD *cmd) {
return new DISPATCHER<CMD>::INSTALL(&command_dispatcher, command_name, cmd);
}
void detach_command(DISPATCHER<CMD>::INSTALL *installer) {
delete installer;
}