Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * logging.h
- *
- * provide logging functions for Microservices
- */
- #ifndef __inc_logging_
- #define __inc_logging_ 1
- #include <stdio.h>
- #include <stdlib.h>
- #include "libpq-fe.h"
- #include <gcrypt.h>
- #include <string.h>
- #include <assert.h>
- #include <sys/time.h>
- #define MAXLOGSIZE 1024
- #define BUFFER_MAXSIZE 2048
- #define MAXFILENAMELEN 1024
- #define HASH_TYPE GCRY_MD_MD5
- #define HASH_NAME "md5"
- // int debug = 1;
- PGconn *conn;
- /** close database connection
- */
- void exit_nicely ( );
- /** query database - TODO umstricken
- * @param const char* query
- */
- PGresult* pquery ( const char *query );
- /** create a sexp for the sign parameters
- * @param gcry_sexp_t *sign_parms holds the result (parameters for signing)
- * @param const char *plain holds the string to be signed
- */
- void make_sign_parameters ( gcry_sexp_t *sign_parms, const char *plain );
- /** verifies a signature
- * @param char *message plain text message
- * @param gcry_sexp_t sig signature of which the validity is to be checked
- * @param gcry_sexp_t pubkey public key that will be used for the check
- */
- gcry_error_t verifysig ( char* message, gcry_sexp_t sig, gcry_sexp_t pubkey );
- /** write a sexp in GCRY_FMT_ADVANCED Format to *filename
- * @param const char *filename holds the filename to be written to
- * @param gcry_sexp_t *sexp holds the sexp to be written
- */
- int write_sexptofile ( const char *filename, gcry_sexp_t *sexp );
- /** reads a sexp from a file given by handle
- * @param FILE *handle is the file handle of the for reading opened file
- * @param gcry_sexp_t *sexp holds the result
- */
- int read_sexpfromfile ( const char *filename , gcry_sexp_t *sexp );
- /** obtains a keypair either through generating it or by reading ot from the files in the global skey and pkey variables
- * @param gcry_sexp_t *skey is a sexp that will hold the secret key after reading
- * @param gcry_sexp_t *pubkey a sexp that will hold the public key after reading
- */
- void obtainkeys ( gcry_sexp_t* skey, gcry_sexp_t* pubkey );
- /** sign a message using a given skey and store result in *sig
- * @param const char *message is the plain text message to be signed
- * @param gcry_sexp_t *sig is a pointer to where the signature sexp will be stored
- * @param gcry_sexp_t *skey is a pointer to the secret key that will be used for signing
- */
- gcry_error_t sign ( const char *message, gcry_sexp_t *sig, gcry_sexp_t *skey );
- /** sets the string *target to the content of *fname
- * @param char *target is the target to be written to
- * @param const char *fname holds the new filename
- */
- int setfname ( char *target, const char *fname );
- /** logs a message to a postgresql server. the primary key will be auto incremented and is not included in the log. A Time is automatically created and logged with the rest of the data
- * @param const char *user
- * @param const char *service
- * @param const char *dig_obj
- * @param const char *message
- */
- int logmessage ( const char *user, const char *service, const char *dig_obj, const char *message );
- /** converts the null terminated string id to a long long
- * @param char *id
- */
- long long stringtolong(const char *id);
- // sexp ausgeben
- void
- print_sexp(gcry_sexp_t sexp);
- // returning something negative on an internal error
- // if verification fails it will return the ID of the first failed row
- // will start verification at id so this can resume a verification if it failed previously
- long long verifyrows ( char * dig_obj, unsigned long long id );
- // ATM this function is full of shit
- void print_pgresult ( PGresult **res );
- long long mypow(long long i, long long j);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement