File: status.c

package info (click to toggle)
libgadu 1%3A1.9.0-2%2Bsqueeze2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,828 kB
  • ctags: 735
  • sloc: ansic: 10,507; sh: 10,195; perl: 320; makefile: 161
file content (51 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * przykład prostego programu łączącego się z serwerem i zmieniającego opis.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "libgadu.h"

int main(int argc, char **argv)
{
	struct gg_session *gs;
	struct gg_login_params glp;

	if (argc < 4) {
		fprintf(stderr, "użycie: %s <mójnumerek> <mojehasło> <opis>\n", argv[0]);
		return 1;
	}

	gg_debug_level = 255;

	memset(&glp, 0, sizeof(glp));
	glp.uin = atoi(argv[1]);
	glp.password = argv[2];
//	glp.encoding = GG_ENCODING_UTF8;
//	glp.protocol_version = 0x2d;
	glp.status = GG_STATUS_INVISIBLE_DESCR;
	glp.status_descr = argv[3];
	
	if (!(gs = gg_login(&glp))) {
		printf("Nie udało się połączyć: %s\n", strerror(errno));
		gg_free_session(gs);
		return 1;
	}

	gg_notify(gs, NULL, 0);

	printf("Połączono.\n");

	if (gg_change_status_descr(gs, GG_STATUS_NOT_AVAIL_DESCR, argv[3]) == -1) {
		printf("Połączenie przerwane: %s\n", strerror(errno));
		gg_free_session(gs);
		return 1;
	}

	gg_logoff(gs);
	gg_free_session(gs);

	return 0;
}