aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2020-09-11 14:16:23 +0200
committerache <ache@ache.one>2020-09-11 14:16:23 +0200
commit1fb715e1c39302076f058ac9abc7a360a15d1b32 (patch)
tree69e8edaefb70567bae8ba57aabd04f37c842baa0
parentFix confirm send resize (diff)
Call gammu without system
-rw-r--r--main.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/main.c b/main.c
index 20ffea5..1a1b532 100644
--- a/main.c
+++ b/main.c
@@ -399,7 +399,7 @@ int main(int argc, char* argv[]){
int fd = mkstemp(fileName);
close(fd);
- char* cmd = malloc( 2 + strlen(defaultEditor) +
+ char* cmd = malloc(2 + strlen(defaultEditor) +
strlen(fileName) );
sprintf( cmd, "%s %s", defaultEditor, fileName );
@@ -425,12 +425,26 @@ edit:
contact* d = NULL;
findContact(number, &d);
int ret = 0;
+
if( (ret = confirmSend(string, d->display_name)) == 1 ) {
- char* cmd = malloc(2048);
- sprintf( cmd, "cat %s | gammu-smsd-inject TEXT %s -len 400 -unicode", fileName,
- number);
- system(cmd);
- }else if( ret == 2 ) {
+ int toGammu[2];
+ pipe(toGammu);
+
+ pid_t cpid = fork();
+ if(cpid == 0) {
+ dup2(toGammu[0], 0);
+ close(toGammu[1]);
+ close(STDOUT_FILENO);
+ execvp("gammu-smsd-inject", (char*[]){"gammu-smsd-inject", "TEXT", number, "-len", "400", "-unicode"});
+ } else if(cpid > 0) {
+ close(toGammu[0]);
+ FILE* gammuInput = fdopen(toGammu[1], "w");
+ if( gammuInput ) {
+ fprintf(gammuInput, "%s", string);
+ fclose(gammuInput);
+ }
+ }
+ } else if( ret == 2 ) {
goto edit;
}
}