Wed, 04 Jun 2025 23:12:27 -0500
Fix log viewing for missing protocols
This works around an issue where we depend on the protocol to determine where
its logs are stored so that you can still view logs for existing accounts if
the protocol plugin is no longer on disk.
This still requires the account to exist with the correct protocol-id to work.
Testing Done:
I manually added on of my old aim accounts that I still have logs from to `accounts.xml`. I then selected `View User Log...` from the `Buddies` menu, selected that aim account and entered a contact who I knew I had logs for and verified that those logs were displayed properly.
Bugs closed: PIDGIN-18096
Reviewed at https://reviews.imfreedom.org/r/4016/
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZGetVariable, ZSetVariable, and ZUnsetVariable | |
| 3 | * functions. | |
| 4 | * | |
| 5 | * Created by: Robert French | |
| 6 | * | |
| 7 | * Copyright (c) 1987 by the Massachusetts Institute of Technology. | |
| 8 | * For copying and distribution information, see the file | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
9 | * "mit-copyright.h". |
| 2086 | 10 | */ |
| 11 | ||
|
18273
e61c53184c52
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
12 | #include "libpurple/internal.h" |
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
13 | #include "internal.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
4272
diff
changeset
|
14 | #include "util.h" |
| 2086 | 15 | |
| 16 | #include <ctype.h> | |
| 10867 | 17 | #ifndef WIN32 |
| 2086 | 18 | #include <pwd.h> |
| 10867 | 19 | #endif |
| 2086 | 20 | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
21 | static char *get_localvarfile __P((void)); |
| 2086 | 22 | static char *get_varval __P((char *fn, char *val)); |
| 23 | static int varline __P((char *bfr, char *var)); | |
| 24 | ||
| 25 | char *ZGetVariable(var) | |
| 26 | char *var; | |
| 27 | { | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
28 | char *varfile, *ret; |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
29 | |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
30 | if ((varfile = get_localvarfile()) == NULL) |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
31 | return ((char *)0); |
| 2086 | 32 | |
|
30617
d79eaf981448
Fix a minor memleak on initialization
Mark Doliner <markdoliner@pidgin.im>
parents:
28001
diff
changeset
|
33 | ret = get_varval(varfile, var); |
|
d79eaf981448
Fix a minor memleak on initialization
Mark Doliner <markdoliner@pidgin.im>
parents:
28001
diff
changeset
|
34 | g_free(varfile); |
|
d79eaf981448
Fix a minor memleak on initialization
Mark Doliner <markdoliner@pidgin.im>
parents:
28001
diff
changeset
|
35 | if (ret != ZERR_NONE) |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
36 | return ret; |
| 2086 | 37 | |
| 10867 | 38 | #ifdef WIN32 |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
39 | varfile = g_strdup("C:\\zephyr\\zephyr.var"); |
| 10867 | 40 | #else |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
41 | varfile = g_strdup_printf("%s/zephyr.vars", CONFDIR); |
| 10867 | 42 | #endif |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
43 | ret = get_varval(varfile, var); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
44 | g_free(varfile); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
45 | |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
46 | return ret; |
| 2086 | 47 | } |
| 48 | ||
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
36256
diff
changeset
|
49 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
36256
diff
changeset
|
50 | ZSetVariable(char *var, char *value) |
| 2086 | 51 | { |
| 52 | int written; | |
| 53 | FILE *fpin, *fpout; | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
54 | char *varfile, *varfilebackup, varbfr[512]; |
| 2086 | 55 | |
| 56 | written = 0; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
57 | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
58 | if ((varfile = get_localvarfile()) == NULL) |
| 2086 | 59 | return (ZERR_INTERNAL); |
| 60 | ||
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
61 | varfilebackup = g_strconcat(varfile, ".backup", NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
62 | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
63 | if (!(fpout = fopen(varfilebackup, "w"))) { |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
64 | g_free(varfile); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
65 | g_free(varfilebackup); |
| 2086 | 66 | return (errno); |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
67 | } |
|
10592
cd4c3a7d7bdf
[gaim-migrate @ 11998]
Daniel Atallah <datallah@pidgin.im>
parents:
10589
diff
changeset
|
68 | if ((fpin = fopen(varfile, "r")) != NULL) { |
| 2086 | 69 | while (fgets(varbfr, sizeof varbfr, fpin) != (char *) 0) { |
| 70 | if (varbfr[strlen(varbfr)-1] < ' ') | |
| 71 | varbfr[strlen(varbfr)-1] = '\0'; | |
| 72 | if (varline(varbfr, var)) { | |
| 73 | fprintf(fpout, "%s = %s\n", var, value); | |
| 74 | written = 1; | |
| 75 | } | |
| 76 | else | |
| 77 | fprintf(fpout, "%s\n", varbfr); | |
| 78 | } | |
| 79 | (void) fclose(fpin); /* don't care about errs on input */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
80 | } |
| 2086 | 81 | if (!written) |
| 82 | fprintf(fpout, "%s = %s\n", var, value); | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
83 | if (fclose(fpout) == EOF) { |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
84 | g_free(varfilebackup); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
85 | g_free(varfile); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
86 | return(EIO); /* can't rely on errno */ |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
87 | } |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
88 | if (rename(varfilebackup, varfile)) { |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
89 | g_free(varfilebackup); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
90 | g_free(varfile); |
| 2086 | 91 | return (errno); |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
92 | } |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
93 | g_free(varfilebackup); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
94 | g_free(varfile); |
| 2086 | 95 | return (ZERR_NONE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
96 | } |
| 2086 | 97 | |
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
36256
diff
changeset
|
98 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
36256
diff
changeset
|
99 | ZUnsetVariable(char *var) |
| 2086 | 100 | { |
| 101 | FILE *fpin, *fpout; | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
102 | char *varfile, *varfilebackup, varbfr[512]; |
| 2086 | 103 | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
104 | if ((varfile = get_localvarfile()) == NULL) |
| 2086 | 105 | return (ZERR_INTERNAL); |
| 106 | ||
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
107 | varfilebackup = g_strconcat(varfile, ".backup", NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
108 | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
109 | if (!(fpout = fopen(varfilebackup, "w"))) { |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
110 | g_free(varfile); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
111 | g_free(varfilebackup); |
| 2086 | 112 | return (errno); |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
113 | } |
|
10592
cd4c3a7d7bdf
[gaim-migrate @ 11998]
Daniel Atallah <datallah@pidgin.im>
parents:
10589
diff
changeset
|
114 | if ((fpin = fopen(varfile, "r")) != NULL) { |
| 2086 | 115 | while (fgets(varbfr, sizeof varbfr, fpin) != (char *) 0) { |
| 116 | if (varbfr[strlen(varbfr)-1] < ' ') | |
| 117 | varbfr[strlen(varbfr)-1] = '\0'; | |
| 118 | if (!varline(varbfr, var)) | |
| 119 | fprintf(fpout, "%s\n", varbfr); | |
| 120 | } | |
| 121 | (void) fclose(fpin); /* don't care about read close errs */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
122 | } |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
123 | if (fclose(fpout) == EOF) { |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
124 | g_free(varfilebackup); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
125 | g_free(varfile); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
126 | return(EIO); /* errno isn't reliable */ |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
127 | } |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
128 | if (rename(varfilebackup, varfile)) { |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
129 | g_free(varfilebackup); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
130 | g_free(varfile); |
| 2086 | 131 | return (errno); |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
132 | } |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
133 | g_free(varfilebackup); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
134 | g_free(varfile); |
| 2086 | 135 | return (ZERR_NONE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
136 | } |
| 2086 | 137 | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
138 | static char *get_localvarfile(void) |
| 2086 | 139 | { |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
140 | const char *base; |
| 10867 | 141 | #ifndef WIN32 |
| 2086 | 142 | struct passwd *pwd; |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
143 | base = purple_home_dir(); |
| 10867 | 144 | #else |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
145 | base = getenv("HOME"); |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
146 | if (!base) |
|
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
147 | base = getenv("HOMEPATH"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
148 | if (!base) |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
149 | base = "C:\\"; |
| 10867 | 150 | #endif |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
151 | if (!base) { |
| 10867 | 152 | #ifndef WIN32 |
| 2086 | 153 | if (!(pwd = getpwuid((int) getuid()))) { |
| 154 | fprintf(stderr, "Zephyr internal failure: Can't find your entry in /etc/passwd\n"); | |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
155 | return NULL; |
| 2086 | 156 | } |
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
157 | base = pwd->pw_dir; |
| 10867 | 158 | #endif |
| 2086 | 159 | } |
| 160 | ||
|
28001
c6446d1742d3
Don't use a static buffer to hold a full filename, since it could possibly
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
161 | return g_strconcat(base, "/.zephyr.vars", NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
162 | } |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
163 | |
| 2086 | 164 | static char *get_varval(fn, var) |
| 165 | char *fn; | |
| 166 | char *var; | |
| 167 | { | |
| 168 | FILE *fp; | |
| 169 | static char varbfr[512]; | |
| 170 | int i; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
171 | |
|
10592
cd4c3a7d7bdf
[gaim-migrate @ 11998]
Daniel Atallah <datallah@pidgin.im>
parents:
10589
diff
changeset
|
172 | fp = fopen(fn, "r"); |
| 2086 | 173 | if (!fp) |
| 174 | return ((char *)0); | |
| 175 | ||
| 176 | while (fgets(varbfr, sizeof varbfr, fp) != (char *) 0) { | |
| 177 | if (varbfr[strlen(varbfr)-1] < ' ') | |
| 178 | varbfr[strlen(varbfr)-1] = '\0'; | |
| 179 | if (!(i = varline(varbfr, var))) | |
| 180 | continue; | |
| 181 | (void) fclose(fp); /* open read-only, don't care */ | |
| 182 | return (varbfr+i); | |
| 183 | } | |
| 184 | (void) fclose(fp); /* open read-only, don't care */ | |
| 185 | return ((char *)0); | |
| 186 | } | |
| 187 | ||
| 188 | /* If the variable in the line bfr[] is the same as var, return index to | |
| 189 | the variable value, else return 0. */ | |
| 190 | static int varline(bfr, var) | |
| 191 | char *bfr; | |
| 192 | char *var; | |
| 193 | { | |
| 194 | register char *cp; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
195 | |
| 2086 | 196 | |
| 197 | if (!bfr[0] || bfr[0] == '#') /* comment or null line */ | |
| 198 | return (0); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30617
diff
changeset
|
199 | |
| 2086 | 200 | cp = bfr; |
| 201 | while (*cp && !isspace(*cp) && (*cp != '=')) | |
| 202 | cp++; | |
| 203 | ||
| 10867 | 204 | #ifndef WIN32 |
| 2086 | 205 | #define max(a,b) ((a > b) ? (a) : (b)) |
| 10867 | 206 | #endif |
| 2086 | 207 | |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
208 | if (g_ascii_strncasecmp(bfr, var, max(strlen(var), (gsize)(cp - bfr)))) |
| 2086 | 209 | return(0); /* var is not the var in |
| 210 | bfr ==> no match */ | |
| 211 | ||
| 212 | cp = strchr(bfr, '='); | |
| 213 | if (!cp) | |
| 214 | return(0); | |
| 215 | cp++; | |
| 216 | while (*cp && isspace(*cp)) /* space up to variable value */ | |
| 217 | cp++; | |
| 218 | ||
| 219 | return (cp - bfr); /* return index */ | |
| 220 | } |