Wed, 25 May 2022 23:52:45 -0500
Remove prpl-gtalk from XMPP console
It no longer exists, and complicates the code a bit.
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for asynchronous location functions. | |
| 3 | * | |
| 4 | * Created by: Marc Horowitz | |
| 5 | * | |
| 6 | * Copyright (c) 1990,1991 by the Massachusetts Institute of Technology. | |
| 7 | * For copying and distribution information, see the file | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
8 | * "mit-copyright.h". |
| 2086 | 9 | */ |
| 10 | ||
|
8791
655f64e6d1e2
[gaim-migrate @ 9553]
Christian Hammond <chipx86@chipx86.com>
parents:
7475
diff
changeset
|
11 | #include "internal.h" |
|
40474
1341be8e3402
Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents:
40166
diff
changeset
|
12 | |
|
1341be8e3402
Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents:
40166
diff
changeset
|
13 | #include <purple.h> |
| 2086 | 14 | |
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
15 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
16 | ZRequestLocations(const char *user, ZAsyncLocateData_t *zald, |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
17 | ZNotice_Kind_t kind, /* UNSAFE, UNACKED, or ACKED */ |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
18 | Z_AuthProc auth) |
| 2086 | 19 | { |
| 20 | int retval; | |
| 21 | ZNotice_t notice; | |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
22 | size_t userlen, versionlen; |
| 2086 | 23 | |
|
40643
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
24 | if (ZGetSocket() == NULL) { |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
25 | retval = ZOpenPort(NULL); |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
26 | if (retval != ZERR_NONE) { |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
27 | return retval; |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
28 | } |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
29 | } |
| 2086 | 30 | |
| 31 | (void) memset((char *)¬ice, 0, sizeof(notice)); | |
| 32 | notice.z_kind = kind; | |
| 33 | notice.z_port = __Zephyr_port; | |
| 34 | notice.z_class = LOCATE_CLASS; | |
| 35 | notice.z_class_inst = user; | |
| 36 | notice.z_opcode = LOCATE_LOCATE; | |
| 37 | notice.z_sender = 0; | |
| 38 | notice.z_recipient = ""; | |
| 39 | notice.z_default_format = ""; | |
| 40 | notice.z_message_len = 0; | |
| 41 | ||
| 42 | if ((retval = ZSendNotice(¬ice, auth)) != ZERR_NONE) | |
| 43 | return(retval); | |
| 44 | ||
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
45 | userlen = strlen(user) + 1; |
|
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
46 | versionlen = strlen(notice.z_version) + 1; |
|
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
47 | if ((zald->user = (char *) malloc(userlen)) == NULL) { |
| 2086 | 48 | return(ENOMEM); |
| 49 | } | |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
50 | if ((zald->version = (char *) malloc(versionlen)) == NULL) { |
| 2086 | 51 | free(zald->user); |
| 52 | return(ENOMEM); | |
| 53 | } | |
| 54 | zald->uid = notice.z_multiuid; | |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
55 | g_strlcpy(zald->user,user,userlen); |
|
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
56 | g_strlcpy(zald->version,notice.z_version,versionlen); |
| 2086 | 57 | |
| 58 | return(ZERR_NONE); | |
| 59 | } | |
| 60 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
61 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
62 | ZParseLocations(ZNotice_t *notice, ZAsyncLocateData_t *zald, int *nlocs, |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
63 | char **user) |
| 2086 | 64 | { |
| 65 | char *ptr, *end; | |
| 66 | int i; | |
| 67 | ||
| 68 | ZFlushLocations(); /* This never fails (this function is part of the | |
| 69 | library, so it is allowed to know this). */ | |
| 70 | ||
| 71 | /* non-matching protocol version numbers means the | |
| 72 | server is probably an older version--must punt */ | |
| 73 | ||
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
74 | if (zald && !purple_strequal(notice->z_version, zald->version)) |
| 2086 | 75 | return(ZERR_VERS); |
| 76 | ||
| 77 | if (notice->z_kind == SERVNAK) | |
| 78 | return (ZERR_SERVNAK); | |
| 79 | ||
| 80 | /* flag ACKs as special */ | |
| 81 | if (notice->z_kind == SERVACK && | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31955
diff
changeset
|
82 | purple_strequal(notice->z_opcode, LOCATE_LOCATE)) { |
| 2086 | 83 | *nlocs = -1; |
| 84 | return(ZERR_NONE); | |
| 85 | } | |
| 86 | ||
| 87 | if (notice->z_kind != ACKED) | |
| 88 | return (ZERR_INTERNAL); | |
| 89 | ||
| 90 | end = notice->z_message+notice->z_message_len; | |
| 91 | ||
| 92 | __locate_num = 0; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
93 | |
| 2086 | 94 | for (ptr=notice->z_message;ptr<end;ptr++) |
| 95 | if (!*ptr) | |
| 96 | __locate_num++; | |
| 97 | ||
| 98 | __locate_num /= 3; | |
| 99 | ||
| 100 | if (__locate_num) | |
| 101 | { | |
| 102 | __locate_list = (ZLocations_t *)malloc((unsigned)__locate_num* | |
| 103 | sizeof(ZLocations_t)); | |
| 104 | if (!__locate_list) | |
| 105 | return (ENOMEM); | |
| 106 | } else { | |
|
37390
209a1350d87f
Assign pointers to NULL rather than 0.
Michael McConville <mmcconville@mykolab.com>
parents:
37389
diff
changeset
|
107 | __locate_list = NULL; |
| 2086 | 108 | } |
| 109 | ||
| 110 | for (ptr=notice->z_message, i=0; i<__locate_num; i++) { | |
| 111 | unsigned int len; | |
| 112 | ||
| 113 | len = strlen (ptr) + 1; | |
| 114 | __locate_list[i].host = (char *) malloc(len); | |
| 115 | if (!__locate_list[i].host) | |
| 116 | return (ENOMEM); | |
|
31954
e5631d5590cc
Replace numerous strcpy() invocations with strlcpy() in Zephyr.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
117 | g_strlcpy(__locate_list[i].host, ptr,len); |
| 2086 | 118 | ptr += len; |
| 119 | ||
| 120 | len = strlen (ptr) + 1; | |
| 121 | __locate_list[i].time = (char *) malloc(len); | |
| 122 | if (!__locate_list[i].time) | |
| 123 | return (ENOMEM); | |
|
31954
e5631d5590cc
Replace numerous strcpy() invocations with strlcpy() in Zephyr.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
124 | g_strlcpy(__locate_list[i].time, ptr,len); |
| 2086 | 125 | ptr += len; |
| 126 | ||
| 127 | len = strlen (ptr) + 1; | |
| 128 | __locate_list[i].tty = (char *) malloc(len); | |
| 129 | if (!__locate_list[i].tty) | |
| 130 | return (ENOMEM); | |
|
31954
e5631d5590cc
Replace numerous strcpy() invocations with strlcpy() in Zephyr.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
131 | g_strlcpy(__locate_list[i].tty, ptr,len); |
| 2086 | 132 | ptr += len; |
| 133 | } | |
| 134 | ||
| 135 | __locate_next = 0; | |
| 136 | *nlocs = __locate_num; | |
| 137 | if (user) { | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31955
diff
changeset
|
138 | size_t len; |
| 2086 | 139 | if (zald) { |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
140 | len = strlen(zald->user) + 1; |
|
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
141 | if ((*user = (char *) malloc(len)) == NULL) |
| 2086 | 142 | return(ENOMEM); |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
143 | g_strlcpy(*user,zald->user,len); |
| 2086 | 144 | } else { |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
145 | len = strlen(notice->z_class_inst) + 1; |
|
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
146 | if ((*user = (char *) malloc(len)) == NULL) |
| 2086 | 147 | return(ENOMEM); |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
148 | g_strlcpy(*user,notice->z_class_inst,len); |
| 2086 | 149 | } |
| 150 | } | |
| 151 | return (ZERR_NONE); | |
| 152 | } | |
| 153 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
154 | int |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
155 | ZCompareALDPred(ZNotice_t *notice, void *zald) |
| 2086 | 156 | { |
| 157 | return(ZCompareUID(&(notice->z_multiuid), | |
| 158 | &(((ZAsyncLocateData_t *) zald)->uid))); | |
| 159 | } | |
| 160 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
161 | void |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
162 | ZFreeALD(ZAsyncLocateData_t *zald) |
| 2086 | 163 | { |
| 164 | if (!zald) return; | |
| 165 | ||
|
37389
7240fd8e3462
free() and g_free() are specified to be NULL-safe. Remove NULL checks.
Michael McConville <mmcconville@mykolab.com>
parents:
31955
diff
changeset
|
166 | free(zald->user); |
|
7240fd8e3462
free() and g_free() are specified to be NULL-safe. Remove NULL checks.
Michael McConville <mmcconville@mykolab.com>
parents:
31955
diff
changeset
|
167 | free(zald->version); |
| 2086 | 168 | (void) memset(zald, 0, sizeof(*zald)); |
| 169 | } |