mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 20:00:58 +01:00
fixes and stuff
This commit is contained in:
11
TODO
11
TODO
@@ -25,19 +25,10 @@ Unitttests:
|
|||||||
ok 28 - check-crypto-unencrypted-secret-message
|
ok 28 - check-crypto-unencrypted-secret-message
|
||||||
public key exported. <=== ???
|
public key exported. <=== ???
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- sometimes secret key is empty
|
- sometimes secret key is empty
|
||||||
|
|
||||||
libpcp/crypto.c: the stream versions must return the output streams, not close them
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
crypto.c: In function 'pcp_encrypt_stream':
|
|
||||||
crypto.c:379: warning: assignment makes integer from pointer without a cast
|
|
||||||
crypto.c:383: warning: assignment makes integer from pointer without a cast
|
|
||||||
|
|
||||||
|
|
||||||
|
cpptest test3 fails, pcpstream backed with buffer behaves komisch
|
||||||
|
|
||||||
|
|
||||||
Python binding, e.g.:
|
Python binding, e.g.:
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ extern "C" {
|
|||||||
#include "pcp/config.h"
|
#include "pcp/config.h"
|
||||||
#include "pcp/base85.h"
|
#include "pcp/base85.h"
|
||||||
#include "pcp/buffer.h"
|
#include "pcp/buffer.h"
|
||||||
#include "pcp/config.h"
|
|
||||||
#include "pcp/crypto.h"
|
#include "pcp/crypto.h"
|
||||||
#include "pcp/defines.h"
|
#include "pcp/defines.h"
|
||||||
#include "pcp/digital_crc32.h"
|
#include "pcp/digital_crc32.h"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#ifndef HAVE_PCP_PCPSTEAM_H
|
#ifndef HAVE_PCP_PCPSTEAM_H
|
||||||
#define HAVE_PCP_PCPSTEAM_H
|
#define HAVE_PCP_PCPSTEAM_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -74,9 +75,15 @@ size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes);
|
|||||||
sets eof and err respectively as ps_read() does. */
|
sets eof and err respectively as ps_read() does. */
|
||||||
size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes);
|
size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes);
|
||||||
|
|
||||||
|
/* use fprintf() style format string to print something out */
|
||||||
|
size_t ps_print(Pcpstream *stream, const char * fmt, ...);
|
||||||
|
|
||||||
/* return the current read or write offset */
|
/* return the current read or write offset */
|
||||||
size_t ps_tell(Pcpstream *stream);
|
size_t ps_tell(Pcpstream *stream);
|
||||||
|
|
||||||
|
/* return a pointer to the internal buffer object */
|
||||||
|
Buffer *ps_buffer(Pcpstream *stream);
|
||||||
|
|
||||||
/* closes the stream and frees allocated memory, if present */
|
/* closes the stream and frees allocated memory, if present */
|
||||||
void ps_close(Pcpstream *stream);
|
void ps_close(Pcpstream *stream);
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Buffer *buffer_new(size_t blocksize, char *name) {
|
Buffer *buffer_new(size_t blocksize, char *name) {
|
||||||
Buffer *b = ucmalloc(sizeof(Buffer));
|
Buffer *b = ucmalloc(sizeof(Buffer));
|
||||||
b->buf = ucmalloc(blocksize);
|
b->buf = ucmalloc(blocksize);
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes) {
|
|||||||
size_t gotbytes = 0;
|
size_t gotbytes = 0;
|
||||||
|
|
||||||
if(stream->is_buffer) {
|
if(stream->is_buffer) {
|
||||||
|
/* check if there's enough space in our buffer */
|
||||||
|
if(buffer_left(stream->b) < readbytes)
|
||||||
|
readbytes = buffer_left(stream->b);
|
||||||
|
|
||||||
gotbytes = buffer_get_chunk(stream->b, buf, readbytes);
|
gotbytes = buffer_get_chunk(stream->b, buf, readbytes);
|
||||||
if(gotbytes == 0) {
|
if(gotbytes == 0) {
|
||||||
/* this should not happen with buffers */
|
/* this should not happen with buffers */
|
||||||
@@ -91,6 +95,23 @@ size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes) {
|
|||||||
return writebytes;
|
return writebytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ps_print(Pcpstream *stream, const char * fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
char *dst;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vasprintf(&dst, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
size_t len = strlen(dst);
|
||||||
|
|
||||||
|
if(stream->is_buffer) {
|
||||||
|
buffer_add(stream->b, dst, len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ps_write(stream, dst, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ps_close(Pcpstream *stream) {
|
void ps_close(Pcpstream *stream) {
|
||||||
if(stream->is_buffer) {
|
if(stream->is_buffer) {
|
||||||
buffer_clear(stream->b);
|
buffer_clear(stream->b);
|
||||||
@@ -123,3 +144,7 @@ size_t ps_tell(Pcpstream *stream) {
|
|||||||
return ftell(stream->fd);
|
return ftell(stream->fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Buffer *ps_buffer(Pcpstream *stream) {
|
||||||
|
return stream->b;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user