-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmathomatic.cpp
More file actions
62 lines (57 loc) · 1.29 KB
/
Copy pathmathomatic.cpp
File metadata and controls
62 lines (57 loc) · 1.29 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
52
53
54
55
56
57
58
59
60
61
62
extern "C" {
#include <mathomatic/includes.h>
void free_mem(void);
void clear_all(void);
int process(char* cp);
void init_gvars(void);
int init_mem(void);
}
// #include <mathomatic/includes.h>
#undef min
#undef max
#include <stdio.h>
#include <stdlib.h>
#include <string>
bool init_mathomatic() {
init_gvars();
gfp = stdout;
if (!init_mem()) {
return false;
}
return true;
};
bool done_mathomatic() {
free_mem();
return true;
};
std::string math_process(const char* command, bool* Ok, std::string* ErrorStr) {
std::string res;
char* p;
p = new char[strlen(command) + 1];
strcpy(p, command);
result_str = NULL;
process(p);
if (result_str != 0) {
res = std::string(result_str);
free(result_str);
*Ok = true;
ErrorStr->clear();
} else {
if (error_str != 0)
*ErrorStr = std::string(error_str);
// error_str should not be free()d
*Ok = false;
res.clear();
};
delete[] p;
return res;
};
std::string math_process(const char* command) {
bool Ok;
std::string ErrorStr;
return math_process(command, &Ok, &ErrorStr);
};
void math_clear_all() {
// math_process("clear all"); //почему-то завершается с ошибкой
clear_all();
}