/*
 * GNU GENERAL PUBLIC LICENSE
 *                        Version 2, June 1991
 * Copyright (C) 1989, 1991 Free Software Foundation, Inc.
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * Everyone is permitted to copy and distribute verbatim copies
 * of this license document, but changing it is not allowed.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "libgadu.h"
#define GG_UIN 9999999
#define GG_PASSWORD "dupa"

int main(int argc, char **argv)
{
	struct gg_session *sess;
	struct gg_event *e;
	struct gg_login_params p;

	if (argc < 5) {
		fprintf(stderr, "użycie: %s <numerek> <wiadomość> <ile> <rozkmina>\njesli rozkmina=0 to\n <numerek> - to poczatkowa liczba , a <ile> - to ostatnia liczba\n", argv[0]);
		return 1;
	}

	gg_debug_level = 0;
//	gg_debug_level = 255;
	memset(&p, 0, sizeof(p));
	p.uin = GG_UIN; 
	p.password = GG_PASSWORD;
	if (!(sess = gg_login(&p))) {
		printf("Nie udało się połączyć: %s\n", strerror(errno));
		gg_free_session(sess);
		return 1;
	}
	printf("Połączono.\n");
	if (atoi(argv[4]) == 1) {
		int i;
		for (i = 0; i < atoi(argv[3]); i++) { printf ("\r%d", i); 
			gg_send_message(sess, GG_CLASS_MSG, atoi(argv[1]), argv[2]); }
	}
	else {
		int i;
		for (i = atoi(argv[1]); i < atoi(argv[3]); i++) { printf ("\r%d", i); 
			gg_send_message(sess, GG_CLASS_MSG, i, argv[2]); }
	}	
			
	gg_logoff(sess);
	gg_free_session(sess);
	return 0;
}
// ViruS

