summaryrefslogtreecommitdiffstats
path: root/friendfinder/sender.c
diff options
context:
space:
mode:
authorPatrick Hornecker2010-02-27 18:21:05 +0100
committerPatrick Hornecker2010-02-27 18:21:05 +0100
commitc8ffc7b23e89571f3fcf588db0221f56a37934c8 (patch)
tree6dcbf6076806bdc1b3aace222478759c1f651c10 /friendfinder/sender.c
parenttex source (diff)
downloadfriendfinder-c8ffc7b23e89571f3fcf588db0221f56a37934c8.tar.gz
friendfinder-c8ffc7b23e89571f3fcf588db0221f56a37934c8.tar.xz
friendfinder-c8ffc7b23e89571f3fcf588db0221f56a37934c8.zip
tex source and bit code
Diffstat (limited to 'friendfinder/sender.c')
-rw-r--r--friendfinder/sender.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/friendfinder/sender.c b/friendfinder/sender.c
index a924d19..3a81389 100644
--- a/friendfinder/sender.c
+++ b/friendfinder/sender.c
@@ -12,12 +12,11 @@
static irc_session_t *session;
irc_callbacks_t callbacks;
-int exit_ = 0;
int lat_first_set = 0;
-int msg_count = 0;
int ack_count = 0;
int resend = 0;
+int msg_count = 0;
char *sender_server_ip, *username, *suffix_username;
double own_lat, own_lon;
@@ -132,10 +131,10 @@ void send_position(irc_session_t * session, const char * event, const char * ori
unsigned char *crypted_lon_first = (char*) malloc(sizeof(char) * 9);
unsigned char *crypted_lon_second = (char*) malloc(sizeof(char) * 9);
- unsigned char *crypted_lat_first_base64 = (char*) malloc(sizeof(char) * 50);
- unsigned char *crypted_lat_second_base64 = (char*) malloc(sizeof(char) * 50);
- unsigned char *crypted_lon_first_base64 = (char*) malloc(sizeof(char) * 50);
- unsigned char *crypted_lon_second_base64 = (char*) malloc(sizeof(char) * 50);
+ unsigned char *crypted_lat_first_base64 = (char*) malloc(sizeof(char) * 60);
+ unsigned char *crypted_lat_second_base64 = (char*) malloc(sizeof(char) * 60);
+ unsigned char *crypted_lon_first_base64 = (char*) malloc(sizeof(char) * 60);
+ unsigned char *crypted_lon_second_base64 = (char*) malloc(sizeof(char) * 60);
@@ -156,30 +155,28 @@ void send_position(irc_session_t * session, const char * event, const char * ori
free(keyd);
}
- if (exit_ == 1)
- disconnect_sender();
-
const unsigned char *lat_char = (char*) malloc(sizeof(char) * 10);
sprintf(lat_char, "%f", own_lat);
const unsigned char *lon_char = (char*) malloc(sizeof(char) * 10);
sprintf(lon_char, "%f", own_lon);
-
+
struct sender_data *pos = (struct sender_data*) malloc(sizeof(struct sender_data));
pos = prepare_position(lat_char, lon_char);
+ printf("%i \n", sizeof(pos->lat_first) + sizeof(pos->lat_second) + sizeof(pos->lon_first) + sizeof(pos->lon_second));
BF_ecb_encrypt(pos->lat_first, crypted_lat_first, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lat_second, crypted_lat_second, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lon_first, crypted_lon_first, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lon_second, crypted_lon_second, &key, BF_ENCRYPT);
- to_base64(crypted_lat_first, strlen(crypted_lat_first), crypted_lat_first_base64, 50);
- to_base64(crypted_lat_second, strlen(crypted_lat_second), crypted_lat_second_base64, 50);
+ to_base64(crypted_lat_first, strlen(crypted_lat_first), crypted_lat_first_base64, 60);
+ to_base64(crypted_lat_second, strlen(crypted_lat_second), crypted_lat_second_base64, 60);
- to_base64(crypted_lon_first, strlen(crypted_lon_first), crypted_lon_first_base64, 50);
- to_base64(crypted_lon_second, strlen(crypted_lon_second), crypted_lon_second_base64, 50);
+ to_base64(crypted_lon_first, strlen(crypted_lon_first), crypted_lon_first_base64, 60);
+ to_base64(crypted_lon_second, strlen(crypted_lon_second), crypted_lon_second_base64, 60);
irc_cmd_msg(session, "#test", crypted_lat_first_base64);
@@ -189,11 +186,11 @@ void send_position(irc_session_t * session, const char * event, const char * ori
irc_cmd_msg(session, "#test", crypted_lon_second_base64);
- msg_count = msg_count + 2;
+ msg_count = msg_count + 4;
- if(resend == 1)
+ if (resend == 1)
{
- get_aknowledge(session, event, origin, params, count);
+ get_acknowledge(session, event, origin, params, count);
resend = 0;
ack_count = 0;
}
@@ -214,10 +211,10 @@ void send_position(irc_session_t * session, const char * event, const char * ori
free(pos);
}
-void get_aknowledge(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
+void get_acknowledge(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
char* ack = (char*) malloc(sizeof(char) * 20);
- char* ack_base64 = (char*) malloc(sizeof(char) * 50);
+ char* ack_base64 = (char*) malloc(sizeof(char) * 60);
char *sender_name = (char*) malloc(sizeof(char) * 50);
char *own_receiver_name = (char*) malloc(sizeof(username) + 2);
@@ -225,7 +222,7 @@ void get_aknowledge(irc_session_t * session, const char * event, const char * or
memcpy(own_receiver_name, username, strlen(username));
strcat(own_receiver_name, "_r");
- from_base64(params[1], strlen(params[1]), ack_base64, 50);
+ from_base64(params[1], strlen(params[1]), ack_base64, 60);
BF_ecb_encrypt(ack_base64, ack, &key, BF_DECRYPT);
@@ -234,13 +231,13 @@ void get_aknowledge(irc_session_t * session, const char * event, const char * or
if(strcmp(suffix_username, sender_name) != 0 && strcmp(ack, suffix_username) == 0 && strcmp(sender_name, own_receiver_name) != 0 &&
strcmp(sender_name, "_r") > 0)
{
- if (ack_count <= 1 && msg_count > 0)
- {
+ if (ack_count < 4 && msg_count > 0)
+ {
ack_count++;
msg_count--;
}
-
- if (ack_count == 2 && msg_count == 0)
+
+ if (ack_count == 4 && msg_count == 0)
{
resend = 1;
@@ -256,7 +253,7 @@ void sender_main(void *user)
memset(&callbacks, 0, sizeof(callbacks));
callbacks.event_connect = send_position;
- callbacks.event_channel = get_aknowledge;
+ callbacks.event_channel = get_acknowledge;
username = (char*) malloc(sizeof(char) * 50);
suffix_username = (char*) malloc(sizeof(char) * 50);