about summary refs log tree commit diff stats
path: root/src/common.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix random string generationMichael Vetter2021-04-171-1/+2
| | | | | | | | | | | | | Our variable `alphabet` contains 62 alphanumeric symbols + '\0'. When we use sizeof(alphabet) we will get 63 due to that. But we want to choose a random numbers from the 62 alphanumeric letters only. This mistake caused us to have strings with a max length of `length` instead of the exact length. When doing https://github.com/profanity-im/profanity/issues/1520 this caused our algo for muc reflection to not catch since we expect the random ID to be exactly 15 symbols long in `message_is_sent_by_us()`.
* Get rid of asprintf and _GNU_SOURCE defineMichael Vetter2021-03-301-4/+3
| | | | | | | _GNU_SOURCE was even in some files where it was not needed at all (http*). Let's replace asprintf() with g_strdup_printf().
* Remove "file://" from file namesMaximilian Wuttke2021-03-091-0/+3
| | | | | Rationale: When copying an image in some application, a URL instead of a path is copied to the clipboard.
* Update copyrightMichael Vetter2021-01-081-1/+1
|
* Do not inherit stdin of main processWilliam Wennerström2020-12-151-1/+1
| | | | I see no reason to inherit the stdin, so let's have it disabled.
* Refactor call_externalWilliam Wennerström2020-12-111-78/+21
|
* Remove stray +2 for path string in get_expanded_pathWilliam Wennerström2020-12-091-6/+6
|
* Allocate memory for realpath in both casesMichael Vetter2020-12-091-1/+1
| | | | Forgot about that :(
* Expand ~ in unique_filename_from_url()Michael Vetter2020-12-091-3/+27
| | | | | | | | unique_filename_from_url() is used for `/url save`. It doesn't recognize ~ by itself, we need to expand it first. Mentioned in https://github.com/profanity-im/profanity/pull/1375#pullrequestreview-547892462
* Rework url to filenameWilliam Wennerström2020-12-061-29/+36
|
* Move unique_filename_from_url functions to commonWilliam Wennerström2020-12-041-0/+80
|
* Refactor for threaded external executable for built-in download methodsWilliam Wennerström2020-12-031-0/+20
|
* Declare counter var inside loopMichael Vetter2020-11-091-4/+2
| | | | We require c99/gnu99 anyways.
* Get rid of str_contains()Michael Vetter2020-11-021-12/+0
| | | | We can use strchr() here.
* Basic support for building on NetBSD.nia2020-09-041-0/+2
| | | | | | - Add NetBSD as a recognized platform without -ldl. - Allow building with NetBSD libcurses instead of ncurses. - Portability to NetBSD sh - use POSIX '=' instead of '=='.
* Apply coding styleMichael Vetter2020-07-071-91/+86
|
* Revert "Apply coding style"Michael Vetter2020-07-071-92/+98
| | | | | | This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2. Sorting the includes creates some problems.
* Apply coding styleMichael Vetter2020-07-071-98/+92
| | | | Regards https://github.com/profanity-im/profanity/issues/1396
* get_mentions() Use gchar instead of charMichael Vetter2020-07-021-2/+2
|
* Fix reading/writing linked filesMichael Vetter2020-06-131-0/+1
| | | | | | "base" was not really base but the filename :-) Fix https://github.com/profanity-im/profanity/issues/1362
* Get output and error streams from the command spawned by external_call()Pierre Mazière2020-06-031-8/+83
| | | | Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
* Create call_external() helper functionMichael Vetter2020-05-201-0/+13
|
* Remove unneeded file_getline()Michael Vetter2020-04-201-44/+0
| | | | Not needed anymore since 0942d98c6116dc4b9b608e7483f1d6a8f62c84d7
* Free GError objectsDmitry Podgorny2020-04-141-0/+2
| | | | | | | | | | glib functions can allocate a GError object that must be freed with g_error_free(). Otherwise a memory leak happens. There are similar unfixed places in omemo, check: grep "&error" src/omemo/omemo.c Fixes #1304.
* Put getting mentions in own functionMichael Vetter2020-02-201-0/+15
| | | | | | So we can use it somewhere else too. Regards https://github.com/profanity-im/profanity/issues/1261
* Update my Copyright to 2020Michael Vetter2020-01-031-1/+1
|
* Add vim modelineMichael Vetter2019-11-131-0/+1
|
* Move code from jid_random_resource() into own functionMichael Vetter2019-10-161-0/+20
| | | | | Move the code that creates a random string into it's own function +get_random_string().
* Check errors in is_dir() is_regular_file()Michael Vetter2019-10-041-2/+10
| | | | | | | In case of error print the error. And return right value. Improvement based on @pasis advice in https://github.com/profanity-im/profanity/pull/1036 Applying in preparation to merge that PR.
* Add myself to copyrightMichael Vetter2019-06-171-0/+1
| | | | Like discussed with James.
* Don't call mblen() to not depend on localeFrank Zschockelt2019-05-221-5/+2
| | | | | | | | | | mblen will fail with return code -1 if the locale used by the unit tests isn't available on the machine. This will lead to an off by one error in some tests where the needle is at the end of the haystack. Since prof_occurrences expect null-terminated strings, the character after the needle can simply be found by incrementing the address of the found needle with strlen(needle).
* Check for new profanity version using new URLMichael Vetter2019-05-031-1/+1
| | | | Regards https://github.com/profanity-im/profanity/issues/1085
* Update copyright to include 2019Michael Vetter2019-01-221-1/+1
|
* Merge pull request #1011 from jubalh/sha1Michael Vetter2018-09-191-17/+0
|\ | | | | Get rid of p_sha1 dependency
| * Move p_sha1_hash() to stanza.cMichael Vetter2018-09-061-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | Move `p_sha1_hash()` from `common.c` to `xmpp/stanza.c` as it is only used in this file and now depends on libstrophe so xmpp is a better namespace folder. Renaming it as `_stanza_create_sha1_hash()`. And making static since only used here. The function cannot be tested in the unit tests anymore. Once functional tests are working again we should write a test for the sha1 functionality.
| * Use libstrophe sha1 functionsMichael Vetter2018-09-051-10/+9
| | | | | | | | | | | | | | Using libstrophes sha1 functions in p_sha1_hash() to get rid of the p_sha1.c dependency. Relates to https://github.com/boothj5/profanity/issues/882
* | Fix extended plugin handling PRPhilip Flohr2018-09-061-10/+4
| | | | | | | | Fixes problems found in PR #999
* | use gio functions for file copyPhilip Flohr2018-09-061-20/+15
|/
* Move ID generation to xmpp folderMichael Vetter2018-08-301-22/+0
| | | | | | | | | | | create_unique_id() was changed to use UUIDs instead of a counter in the last commit. Since now it depends on connection_create_uuid() which is in the xmpp subfolder the function should also be moved there. Renamed it to connection_create_stanza_id() and moved it to src/xmpp/connection.c. Discussion happened in https://github.com/boothj5/profanity/pull/1010
* Use uuid in create_unique_id instead of counterMichael Vetter2018-08-141-11/+7
| | | | | | | | | | | | Message IDs should be unique so they can be used by XEPs like delivery receipts, chat markers, message correction. So far it used a counter so restarting profanity will cause the counter to be 0 again. Let's rather use an UUID since we have such a function in the xmpp/xmpp.h already. Closes https://github.com/boothj5/profanity/issues/998
* Update copyrightJames Booth2018-01-211-1/+1
|
* Set locale in unit testsJames Booth2017-04-291-2/+2
| | | | issue #901
* Use g_utf8_find_ functions for prof_occurrencesJames Booth2017-04-281-4/+11
| | | | issue #901
* Update Glib dependency to 2.40James Booth2017-03-251-48/+0
|
* Allow installing plugins from directoryJames Booth2017-02-051-0/+42
|
* Update CopyrightJames Booth2017-01-281-1/+1
|
* Fix multibyte chars in prof_occurrencesJames Booth2017-01-261-8/+14
| | | | issue #901
* Move window functions to window_list.cJames Booth2016-07-241-73/+0
|
* Move resource conversionsJames Booth2016-07-241-70/+1
|
* Add config/files.cJames Booth2016-07-241-38/+0
|
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475