about summary refs log tree commit diff stats
path: root/src/common.c
Commit message (Collapse)AuthorAgeFilesLines
* Adapt to g_string_free glib 2.75.3 changeMichael Vetter2023-03-211-24/+13
| | | | | | | | | | | | glib 2.75.3 changes warning behaviour of `g_string_free()`. See: * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3219 * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3226 Use this opportunity to replace the use of GString with `g_strdup_printf()` where possible. Otherwise correctly take the return value of `g_string_free()` which is nicer anyways.
* fix #1761 by changing the implementation from recursiveSteffen Jaeckel2023-03-111-23/+22
| | | | | | ... to an iterative approach Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* introduce `auto_gcharv`Steffen Jaeckel2023-01-191-0/+8
| | | | | | This also fixes memory leaks in `_omemo_autocomplete()`. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* fix memory leaks in OMEMOSteffen Jaeckel2023-01-181-0/+7
| | | | Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* add `/strophe` command to modify libstrophe-specific settingsSteffen Jaeckel2023-01-181-10/+32
| | | | Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* Update copyright yearMichael Vetter2023-01-101-1/+1
|
* Spawn external programs asynchronouslyMarouane L2022-10-121-30/+11
| | | | | | | | Drawback is that we can't check the exitcode anymore. But we were unsure why/when we need this, see: https://github.com/profanity-im/profanity/pull/1760/files#r980868708 Fixes https://github.com/profanity-im/profanity/issues/1759
* support for formatting in avatar executablenandesu-utils2022-09-061-12/+12
| | | | | | in before it just used the input command line as it was but this fixes this by adding formatting using `format_call_external_argv` which is already used in `url open` executable.
* refactored call_external codenandesu-utils2022-08-271-17/+22
| | | | | | | | | | | | | | | | unluckily here the code neglected the fact that glib will set an error to a location that was pointed by the error pointer if it is not null. but it was of an undefined value hence profanity crashed. now it is null as it must be. also spawn error is returned when glib could not spawn the task for some reason like the executable file does not exist but if the exit status was non-zero it neglected the exit error and tried to output a spawn error instead. now we check whether the process that we instantiated has exited successfully also now code uses `g_spawn_check_wait_status` which `g_spawn_check_exit_status` has been aliased to.
* common: dont use GError twiceMichael Vetter2022-08-021-7/+15
| | | | | | We need to use a new one or call `g_clear_error()`. Fix segfault in https://github.com/profanity-im/profanity/issues/1738
* Check for error before trying to append itMichael Vetter2022-08-021-1/+1
| | | | Related to https://github.com/profanity-im/profanity/issues/1738
* Update copyright yearMichael Vetter2022-05-091-1/+1
|
* use `g_mkdir_with_parents()` instead of home-baked solutionSteffen Jaeckel2022-03-141-32/+4
| | | | Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* 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