summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/util.h
AgeCommit message (Collapse)AuthorFilesLines
2011-06-14Switch all logging to use handle directlyDan McGee1-3/+3
This is the last user of our global handle object. Once again the diff is large but the functional changes are not. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Move pm_errno onto the handleDan McGee1-6/+9
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_option_(get|set)_*() methodsDan McGee1-2/+2
This requires a lot of line changes, but not many functional changes as more often than not our handle variable is already available in some fashion. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to alpm_logaction()Dan McGee1-1/+1
This is the first in a series of patches to update the API to remove the implicit global handle variable. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove global handle from util.cDan McGee1-2/+3
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-04Deal with unused function parameters correctlyAllan McRae1-0/+2
This started off removing the "(void)foo" hacks to work around unused function parameters and ended up fixing every warning generated by -Wunused-parameter. Dan: rename to UNUSED. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-29Merge branch 'maint'Dan McGee1-0/+4
2011-03-29alpm/handle.c: ensure handle is not NULL before proceedingRémy Oudompheng1-0/+4
Many alpm_option_get/set_*() functions already check this and set pm_errno to the right value, but not all, so this improves consistency. Signed-off-by: Rémy Oudompheng <remy@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23lib/dload.c: fix compiler warnings generated by -Wfloat-equalDave Reisner1-0/+4
* introduces new macro in util.h (DOUBLE_EQ) for properly comparing floating point values Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21Style change: return(x) --> return xDan McGee1-1/+1
This was discussed and more or less agreed upon on the mailing list. A huge checkin, but if we just do it and let people adjust the pain will end soon enough. Rebasing should be relatively straighforward for anyone that sees conflicts; just be sure you use the new return style if possible. The following semantic patch was used to do the change, along with some hand-massaging in order to preserve parenthesis where appropriate: The semantic match that finds this problem is as follows, although some hand-massaging was done in order to keep parenthesis where appropriate: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a; @@ - return(a); + return a; // </smpl> A macros_file was also provided with the following content: Additional steps taken, mainly for ASSERT() macros: $ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c $ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20Add missing include for size_tDan McGee1-0/+1
Needed for things like our strndup() substitute function. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28Move locking functions to where they are neededDan McGee1-2/+0
We only call these from the transaction init and teardown, so move them to that file, mark them static, and push more of the logic of handle manipulation into these functions. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-27Fix double close of the lock fileJonathan Conder1-1/+1
According to FOPEN(3), using fclose on an fdopen'd file stream also closes the underlying file descriptor. This happened in _alpm_lckmk (util.c), which meant that when alpm_trans_release closed it again, the log file (which reused the original file descriptor) was closed instead. Signed-off-by: Jonathan Conder <jonno.conder@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21Add strndup fallback function to libalpm utilDan McGee1-0/+5
The same fallback we are currently using in the pacman frontend. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-08Refactor old date parsing into single methodDan McGee1-0/+1
We've managed to duplicate this four times at this point, so make it a method in util.c instead. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-08Update copyright years for 2011Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-21Overhaul archive fgets functionDan McGee1-1/+17
The old function was written in a time before we relied on it for nearly every operation. Since then, we have switched to the archive backend and now fast parsing is a big deal. The former function made a per-character call to the libarchive archive_read_data() function, which resulted in some 21 million calls in a typical "load all sync dbs" operation. If we instead do some buffering of our own and read the blocks directly, and then find our newlines from there, we can cut out the multiple layers of overhead and go from archive to parsed data much quicker. Both users of the former function are switched over to the new signature, made easier by the macros now in place in the sync backend parsing code. Performance: for a `pacman -Su` (no upgrades available), _alpm_archive_fgets() goes from being 29% of the total time to 12% The time spent on the libarchive function being called dropped from 24% to 6%. This pushes _alpm_pkg_find back to the title of slowest low-level function. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-21Always specify arguement type in function delcarationsAllan McRae1-2/+2
Always declare a function with (void) rather than () when we expect no arguements. Fixes all warnings with -Wstrict-prototypes. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Add hash_sdbm functionDan McGee1-0/+1
This is prepping for the addition of a hash field to each package to greatly speed up the string comparisons we frequently do on package name in _alpm_pkg_find. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Move MAX_DELTA_RATIO definitionAllan McRae1-3/+0
This is a delta specific definition so it makes more sense to put it in the delta specific header file. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-14Move and rename splitnameAllan McRae1-0/+2
The splitname function is a general utility function and so is better suited to util.h. Rename it to _alpm_splitname to indicate it is an internal libalpm function as was the case prior to splitting local and sync db handling. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-08-27use execv to avoid using sh just to run ldconfigJonathan Conder1-1/+1
Signed-off-by: Jonathan Conder <j@skurvy.no-ip.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-15Bump copyright dates to 2010Dan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11Rework the alpm_unpack functionsXavier Chantry1-1/+4
Add support to extract a list of entries Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11int typing: s/unsigned short/int/ in libalpmDan McGee1-1/+1
After our recent screwup with size_t and ssize_t in the download code, I found the `-Wsign-conversion` flag to GCC to see if we were doing anything else boneheaded. I didn't find anything quite as bad, but we did have some goofups- most of our public unsigned methods would return -1 on error, which is a bit odd in an unsigned context. Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-07libalpm/util.c : remove _alpm_strreplaceXavier Chantry1-1/+0
This function is unused since commit 358cc5804a2df873180e6d9ef2420ab3247f8437. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> [Dan: also kill from util.h] Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-16Run ldconfig inside chroot.Xavier Chantry1-0/+1
This fixes FS#15294. The code to run a command inside a chroot was refactored from the _alpm_runscriptlet function to _alpm_run_chroot. Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-07-01Update copyright headers and messagesDan McGee1-1/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-25Remove unused strverscmp substituteDan McGee1-3/+0
Our internal vercmp function was the only user of this, and it no longer relies on it. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-19Remove unnecessary NULL check in FREE() macroDan McGee1-1/+1
free() is designed to do nothing if it is passed a NULL pointer, so there is no need to check for it on our end. Change/fix the macro. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-07Remove unnecessary header file, move one macro to util.cDan McGee1-0/+4
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-27Add an archive_fgets() functionDan McGee1-0/+2
This crude function allows reading from an archive on a line-by-line basis similar to the familiar fgets() call on a FILE stream. This is the first step in being able to read DB entries straight from an archive. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-28libalpm: clean up of md5sum functions.Chantry Xavier1-0/+1
test_delta_md5sum and test_pkg_md5sum were simple wrappers to test_md5sum, and only used once, so not very useful. I removed them. Also, test_md5sum and alpm_pkg_checkmd5sum functions were a bit duplicated, so I refactored them with a new _alpm_test_md5sum function in libalpm/util.c Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-01-15Merge branch 'maint'Dan McGee1-0/+1
2008-01-14FS#9183 : force correct permissions on tmp/.Jaroslaw Swierczynski1-0/+1
[Xav: removed unneeded makepath_internal function, and fixed the permission value : 1777 -> 01777] Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-11Use dynamic string allocation in package structuresDan McGee1-1/+2
This also affects all structures with static strings, such as depmiss, conflict, etc. This should help a lot with memory usage, and hopefully make things a bit more "idiot proof". Currently our pactest pass/fail rate is identical before and after this patch. This is not to say it is a perfect patch- I have yet to pull valgrind out. However, this should be quite safe to use in all situations from here on out, and we can start plugging the memleaks. Original-work-by: Aaron Griffin <aaronmgriffin@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-11Update GNU GPL boilerplate and copyright datesDan McGee1-4/+2
Update the GPL boilerplate to direct people to the GNU website for a copy of the license, as well as bump all of Judd's copyrights to 2007. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17War on whitespaceDan McGee1-3/+3
Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-16libalpm: simplify sync db lastupdateDan McGee1-1/+0
Legacy code is hitting the trash here. Remove unnecessary _alpm_time2string time storage abstraction in favor of just writing the time_t value to the disk. The only drawback is that everyone's sync DBs will have to be updated at least once so that the lastupdate values are stored right. :) Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-07Add STRDUP macro to mirror MALLOC/CALLOCAaron Griffin1-0/+2
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-11-05libalpm: use an lstat wrapper so we never dereference dir symlinksDan McGee1-0/+2
Linux lstat follows POSIX standards and dereferences a symlink pointing to a directory if there is a trailing slash. For purposes of libalpm, we don't want this so make a lstat wrapper that suppresses this behavior. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-30When printing size_t, use %zdDan McGee1-1/+1
%d was used, which worked for Linux and FreeBSD. Not so for Darwin. The warning was probably spat out when compiling on x68_64 as well, but no developers use this architecture as their primary one. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29libalpm: introduce MALLOC and CALLOC macrosDan McGee1-1/+6
These macros take the place of the common 4 or 5 line blocks of code we had in most places that called malloc or calloc. This should reduce some code duplication and make memory allocation more standard in libalpm. Highlights: * Note that the MALLOC macro actually uses calloc, this is just for safety so that memory is initialized to 0. This can be easily changed in one place. * One malloc call was completely eliminated- it made more sense to do it on the stack. * The use of RET_ERR in public functions (mainly the alpm_*_new functions) was standardized, this makes sense so pm_errno is set. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-23Ensure all localization stuff is correctly guardedDan McGee1-0/+2
Anything dealing with libintl and localization should be correctly guarded inside an ENABLE_NLS block on both the pacman and libalpm sides. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-23Fix broken or missing includesDan McGee1-6/+6
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-23Fix invalid static scoping of strverscmpDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-20Download delta files if UseDelta is set.Nathan Jones1-0/+3
Delta files will be used if the size is smaller than a percent (MAX_DELTA_RATIO) of the package size. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-09Update usage of gcc __attribute__ flagsDan McGee1-1/+1
Change the default visibility of libalpm functions to internal instead of hidden- this allows for slightly better optimization because it tells GCC that the function can never be called outside of the current module (see http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html). Also added some attributes to the pacman print functions so that they check the format strings being passed to them. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-23alpm: removed unused strtoupper wrapper, remove installeddate on parse_descfileDan McGee1-1/+0
installdate should never be present in a package descfile, so get rid of it. With the last commit, we also don't need the util strtoupper function. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-07Add a few missing includes, caught while compiling on cygwinDan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>