omemo/pgp/util.c -> cpp

master
Tony Olagbaiye 2 years ago
parent 7fd3f4ac58
commit f2e711a54a
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -18,7 +18,7 @@ PACKAGES=(
make # Deps with makefiles
cmake # Deps with cmake
doctest # Testing
gcc-toolchain@10 # Compilation
gcc-toolchain@11 # Compilation
pkg-config # Deps configuration and configuration of deps deps
patchelf # Fix linkage (guix)
bear # Generate compile_commands.json for language servers

@ -15,7 +15,7 @@
#include "xmpp/stanza.hh"
#include "config.hh"
#include "input.h"
#include "omemo.h"
#include "omemo.hh"
#include "account.hh"
#include "connection.h"
#include "user.hh"

@ -12,13 +12,13 @@
#include "plugin.hh"
#include "account.hh"
#include "omemo.h"
#include "omemo.hh"
#include "user.hh"
#include "channel.hh"
#include "input.h"
#include "buffer.h"
#include "pgp.h"
#include "util.h"
#include "pgp.hh"
#include "util.hh"
const char *channel__transport_name(enum t_channel_transport transport)
{

@ -18,9 +18,9 @@
#include "user.hh"
#include "channel.hh"
#include "connection.h"
#include "omemo.h"
#include "pgp.h"
#include "util.h"
#include "omemo.hh"
#include "pgp.hh"
#include "util.hh"
#include "diff/diff.h"
void connection__init()

@ -20,7 +20,7 @@ CFLAGS+=$(DBGCFLAGS) \
$(INCLUDES)
CPPFLAGS+=$(DBGCFLAGS) \
-fno-omit-frame-pointer -fPIC \
-std=c++17 -gdwarf-4 \
-std=c++20 -gdwarf-4 \
-Wall -Wextra -pedantic \
-Wno-missing-field-initializers \
$(INCLUDES)
@ -49,10 +49,10 @@ HDRS=plugin.hh \
connection.h \
input.h \
message.h \
omemo.h \
pgp.h \
omemo.hh \
pgp.hh \
user.hh \
util.h \
util.hh \
xmpp/stanza.hh \
SRCS=plugin.cpp \
@ -65,10 +65,10 @@ SRCS=plugin.cpp \
connection.c \
input.c \
message.c \
omemo.c \
pgp.c \
omemo.cpp \
pgp.cpp \
user.cpp \
util.c \
util.cpp \
xmpp/presence.cpp \
xmpp/iq.cpp \

File diff suppressed because it is too large Load Diff

@ -10,7 +10,7 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "pgp.h"
#include "pgp.hh"
#define RNP_SUCCESS 0
@ -26,7 +26,7 @@ void pgp__init(struct t_pgp **pgp, const char *pub, const char *sec)
struct t_pgp *new_pgp;
rnp_input_t keyring;
new_pgp = calloc(1, sizeof(**pgp));
new_pgp = (struct t_pgp*)calloc(1, sizeof(**pgp));
if (rnp_ffi_create(&new_pgp->context,
RNP_KEYSTORE_GPG, RNP_KEYSTORE_GPG) != RNP_SUCCESS) {
@ -164,7 +164,7 @@ char *pgp__decrypt(struct t_gui_buffer *buffer, struct t_pgp *pgp, const char *c
rnp_result_t ret;
buf_len = strlen(PGP_MESSAGE_HEADER) + strlen(ciphertext) + strlen(PGP_MESSAGE_FOOTER) + 1;
buf = malloc(sizeof(char) * buf_len);
buf = (uint8_t*)malloc(sizeof(char) * buf_len);
buf_len = snprintf((char *)buf, buf_len, PGP_MESSAGE_HEADER "%s" PGP_MESSAGE_FOOTER, ciphertext);
/* create file input and memory output objects for the encrypted message and decrypted
@ -213,7 +213,7 @@ char *pgp__verify(struct t_gui_buffer *buffer, struct t_pgp *pgp, const char *ce
rnp_result_t ret;
buf_len = strlen(PGP_SIGNATURE_HEADER) + strlen(certificate) + strlen(PGP_SIGNATURE_FOOTER) + 1;
buf = malloc(sizeof(char) * buf_len);
buf = (uint8_t*)malloc(sizeof(char) * buf_len);
buf_len = snprintf((char *)buf, buf_len, PGP_SIGNATURE_HEADER "%s" PGP_SIGNATURE_FOOTER, certificate);
/* create file input memory objects for the signed message and verified message */

Binary file not shown.

@ -4,11 +4,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strophe.h>
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "util.h"
#include "util.hh"
int char_cmp(const void *p1, const void *p2)
{
@ -18,26 +19,26 @@ int char_cmp(const void *p1, const void *p2)
char *exec(const char *command)
{
// use hook_process instead!
char buffer[128];
char **result = weechat_string_dyn_alloc(256);
// Open pipe to file
FILE* pipe = popen(command, "r");
if (!pipe) {
return "popen failed!";
}
// read till end of process:
while (!feof(pipe)) {
// use buffer to read and add to result
if (fgets(buffer, 128, pipe) != NULL)
weechat_string_dyn_concat(result, buffer, -1);
}
pclose(pipe);
weechat_string_dyn_free(result, 0);
return *result;
char buffer[128];
char **result = weechat_string_dyn_alloc(256);
// Open pipe to file
FILE* pipe = popen(command, "r");
if (!pipe) {
return (char*)strdup("popen failed!");
}
// read till end of process:
while (!feof(pipe)) {
// use buffer to read and add to result
if (fgets(buffer, 128, pipe) != NULL)
weechat_string_dyn_concat(result, buffer, -1);
}
pclose(pipe);
weechat_string_dyn_free(result, 0);
return *result;
}
char *stanza_xml(xmpp_stanza_t *stanza)

@ -2,13 +2,10 @@
// License, version 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef _WEECHAT_XMPP_UTIL_H_
#define _WEECHAT_XMPP_UTIL_H_
#pragma once
int char_cmp(const void *p1, const void *p2);
char *exec(const char *command);
char *stanza_xml(struct _xmpp_stanza_t *stanza);
#endif /*WEECHAT_XMPP_UTIL_H*/
Loading…
Cancel
Save