113 Commits

Author SHA1 Message Date
Corentin Noël
28958bc18a Incorporate some fixes to the meson build definition
Notably the missing gphoto2-endian.h generation was missing
2025-01-13 11:04:13 +01:00
Corentin Noël
f5bb6c875c Add Meson build system 2025-01-08 10:10:36 +01:00
axxel
f41df32817 fix white-space and indentation inconsistencies (second round)
This is basically a continuation of the work from #1002 but her for the
camlibs directory. The purpose was to replace spaces as a means for
indentation with tab characters.

Note: there are some files which are still offending the general
rule but are (mostly) consistent within themselves. I let them be for
the moment. Fixing them would basically replace the whole file.

Also: there are still a ton of whitespace related inconsistencies like
"x=10" vs "x = 10" or "func(10)" vs "func (10)".

This is a whitespace only change (if you include newlines as whitespace).
2024-09-15 10:53:41 +02:00
axxel
87e158c23e introduce helper function aprintf(fmt, ...) (#1010)
This replaces the verbose and error prone pattern of calling
    str = malloc(strlen("some value is 12345678"));
    sprintf(str, "some value is %d", val)
with
    str = aprintf(some value is %d", val);


This is similar to the GNU function asprintf() but returns the pointer
instead of assigning it to the first parameter. It uses the existing
gpi_vsnprintf(fmt, va_list) function.
2024-09-12 13:07:52 +02:00
axxel
742b4db660 White space cleanup #3 (#1005)
* remove trailing whitespace in *.c/*.h files

This is now 'enforced' via .editoconfig. Do it here once to prevent random
ws changes during editing.

* Cleanup intra-line whitespace in large submenu tables in config.c

Consistently use spaces to layout columns, to make it independent of tab
size.

---------

Co-authored-by: axxel <awagger@web.de>
2024-09-05 14:55:44 +02:00
axxel
5c9d7b2759 fix white-space and indentation inconsistencies in ... (#1002)
* examples
 * gphoto2
 * libgphoto2
 * libgphoto2_port

The code (at least in this part of the project) is effectively formated
using tabs with a tab-size of 8 as a means for indentation.

There have been a few places where spaces were introduced. Some obviously
with an indent size of 8 in mind, others with an indent size of 4.

This commit tries its best to make the use of tabs consistent again, at
least for indenting lines. The "intra line" indentation (white space after
the first non-white-space character) is still a bit of a mess.

Co-authored-by: axxel <awagger@web.de>
2024-09-05 09:25:57 +02:00
axxel
1dabc5a523 remove unnecessary if (not-null) check before calling free() (#1001)
Co-authored-by: axxel <awagger@web.de>
2024-09-05 09:25:16 +02:00
Hans Ulrich Niedermann
67ae87e169 Fix -Wcalloc-transposed-args warnings
This switches the arguments of calloc() in a few cases such that
the sizeof() does not happen in the nmemb first argument.

An example warning would be
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]

This is the variant of commit f97c27efe9
with the typo removed which broke compilation.
2024-01-31 23:21:24 +01:00
Hans Ulrich Niedermann
a57b7d8f05 Revert "Fix -Wcalloc-transposed-args warnings"
This reverts commit f97c27efe9.
2024-01-31 23:18:45 +01:00
Hans Ulrich Niedermann
f97c27efe9 Fix -Wcalloc-transposed-args warnings
This switches the arguments of calloc() in a few cases such that
the sizeof() does not happen in the nmemb first argument.

An example warning would be
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
2024-01-31 23:00:11 +01:00
luzpaz
dfde313175 Fix various typos in the codebase (#923)
* Fix various typos

Found via `codespell -q 3 -S "*.po" -L clen,donn,informations,udo`

* Fix typos in camlibs/

* Fix typos in ChangeLog
2023-09-03 17:04:21 +02:00
Hans Ulrich Niedermann
6b595a34ad Define main function as "int main(void)" (with void) 2022-11-11 09:55:40 +01:00
Ingvar Stepanyan
51d5d4a083 Fix GP_UNKNOWN_EVENT leaks in examples (#833)
Most of the examples give wrong impression that `GP_UNKNOWN_EVENT` data does not need to be freed / is not heap allocated, however it's not the case - those messages are always `malloc`'d by corresponding drivers.
2022-09-21 09:28:25 +02:00
Hans Ulrich Niedermann
919671c89b CI: build automake based example project
Add automake based example project using libgphoto2 to have
the CI builds ensure that building a libgphoto2 frontend
with this libgphoto2 is possible.
2022-01-23 15:41:05 +01:00
Marcus Meissner
e43230ef45 avoid crash on freed memory 2021-11-28 15:28:37 +01:00
Hans Ulrich Niedermann
06714b364e examples: Force #include beginning with "libgphoto2/" 2021-10-25 03:34:16 +02:00
Hans Ulrich Niedermann
3730b4cf9b example: include <unistd.h> for close(2), unlink(2), getpid(2) 2021-10-25 00:13:03 +02:00
Hans Ulrich Niedermann
0dbeaf7cbf Use consistently named non-reserved CPP macros for header files
C preprocessor macros beginning/ending with underscores are
reserved for system use as well as macros containing a double
underscore anywhere, so application software macros are
supposed to be named differently.

For a header file gphoto2-abilities-list.h, this
consistently uses a macro name
LIBGPHOTO2_GPHOTO2_ABILITIES_LIST_H
for the usual

    #ifndef LIBGPHOTO2_GPHOTO2_ABILITIES_LIST_H
    #define LIBGPHOTO2_GPHOTO2_ABILITIES_LIST_H
    ... content of the header file ...
    #endif /* !defined(LIBGPHOTO2_GPHOTO2_ABILITIES_LIST_H) */

Found using "clang -Weverything".

This should work, unless when run with an ancient C preprocessor
which might only the first 8 or 10 characters to distinguish
macro names and ignores the remainder of the name.
2021-10-05 16:07:20 +02:00
Marcus Meissner
ab33b92159 report file info 2021-10-03 14:54:05 +02:00
Marcus Meissner
dc8cbddac4 report only if flag set 2021-10-02 13:26:40 +02:00
Marcus Meissner
409dfcedf4 report file info for debugging 2021-10-02 13:23:36 +02:00
Marcus Meissner
6a8a41e7a5 better comments 2021-10-02 12:02:18 +02:00
Hans Ulrich Niedermann
0f5195cc89 use the proper word
libraries are also binaries. What this comment talks about is
executables (the stuff with main() functions).
2021-09-30 18:06:29 +02:00
Marcus Meissner
cf20840d73 added comment how to build fuzzer, and current problems 2021-09-28 11:09:14 +02:00
Marcus Meissner
e9548fd45e added sample-libfuzz ... semi-uable for libfuzzer 2021-09-27 13:48:44 +02:00
Marcus Meissner
c0d4de1eca start a sample for libfuzz 2021-09-26 14:03:32 +02:00
Marcus Meissner
402a43d9af remove memory leaks 2021-08-10 16:28:04 +02:00
Rafał Hirsz
fde666be12 Add _DARWIN_C_SOURCE to most files that use string.h (#615)
This change makes it possible to build libgphoto2 on macOS.
2021-01-29 07:54:08 +01:00
Siim Meerits
4d161b4647 Fix examples compilation warnings.
* best-iso.c: Remove or comment out unused variables.
* sample-afl.c: Remove or comment out unused variables.
* sample-capture.c: Fix signed-unsigned compare issue.
* sample-trigger-capture.c: Fix signed-unsigned compare issue.
2020-08-03 08:50:12 +02:00
Siim Meerits
456a1d598b Remove trailing whitespace from all *.h and *.c files. 2020-07-27 17:37:00 +03:00
Marcus Meissner
55b7b003c6 Revert "also test for usbscsi, usbdiskdirect and serial"
This reverts commit dcb34f94e5.

(fixes travis)
2020-05-26 08:16:18 +02:00
Sijawusz Pur Rahnama
fd0be84db5 Fix typos throughout the codebase 2020-05-25 17:55:09 +02:00
Marcus Meissner
dcb34f94e5 also test for usbscsi, usbdiskdirect and serial 2020-03-29 16:12:38 +02:00
Hans Ulrich Niedermann
fb75d3632d examples: Remove unused TESTS= instance
Any TESTS definition causes "make check" to run a test suite,
even if no tests are actually defined.

So we remove the empty TESTS= from examples/Makefile.am, and
keep on using the TESTS in the tests/Makefile.am file.
2020-02-18 18:56:09 +01:00
Marcus Meissner
8cfca5b2dd fix gp_file reference count usage, its a bit weird 2020-01-25 18:14:16 +01:00
Marcus Meissner
560e15d3f4 let the sample-afl do autodetection to allow fuzzing all USB cameras 2019-04-23 11:48:13 +02:00
Marcus Meissner
88df661051 added unistd.h include for older systems 2019-03-09 14:12:25 +01:00
Marcus Meissner
9ae48976c5 disable capture fuzzing 2019-01-20 17:34:53 +01:00
Marcus Meissner
2799307539 try more calls 2019-01-20 17:13:03 +01:00
Marcus Meissner
79e7fdb455 unref the context in afl sample 2018-12-21 10:30:15 +01:00
Marcus Meissner
663401e3c4 c++ protect 2018-10-14 09:21:13 +02:00
Marcus Meissner
76bfee1646 free various event data
added GP_EVENT_FILE_CHANGED
2018-04-16 19:25:28 +02:00
Marcus Meissner
2ea49c29fa also log the domain 2017-07-31 08:11:28 +02:00
Marcus Meissner
9c4aef574b various fixes to free parameters and coverity issues 2017-06-05 19:13:32 +02:00
Marcus Meissner
3ad0c48f38 recursively list directories until the first file is found,
retrieve information and MTP metadata
2017-04-29 13:07:24 +02:00
Marcus Meissner
e366d6a1f0 list folders and files too 2017-04-29 10:16:15 +02:00
Marcus Meissner
f98954b981 add event handling to afl 2016-12-23 18:46:10 +01:00
Marcus Meissner
3afe07dbfd wait_for_Event needs to be run multiple times to drain
the event queue better. otherwise e.g. Nikon DSLR will
never get to the fileadded event.
2016-12-20 08:43:11 +01:00
Marcus Meissner
eae8a13ac2 adjusted code to handled errors and use buffer and file better
fixes https://github.com/gphoto/libgphoto2/issues/118
2016-12-20 07:10:52 +01:00
Marcus Meissner
14041e1af9 trigger capture: do not use file_read, api does not handle sdram capture currently ... :/ 2016-12-18 21:25:55 +01:00