File: status.c

package info (click to toggle)
libgadu 1:1.12.1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,820 kB
  • ctags: 1,649
  • sloc: ansic: 21,459; perl: 370; makefile: 209; sh: 124
file content (76 lines) | stat: -rw-r--r-- 1,907 bytes parent folder | download | duplicates (4)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 *  (C) Copyright 2001-2006 Wojtek Kaniewski <wojtekka@irc.pl>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License Version
 *  2.1 as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
 *  USA.
 */

/*
 * 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"
#include "network.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;
	}

#ifdef _WIN32
	gg_win32_init_network();
#endif

	gg_debug_level = 255;

	memset(&glp, 0, sizeof(glp));
	glp.uin = atoi(argv[1]);
	glp.password = argv[2];
#if 0
	glp.encoding = GG_ENCODING_UTF8;
	glp.protocol_version = GG_PROTOCOL_VERSION_110;
#endif
	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;
}