From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 6830E1387C2 for ; Fri, 1 Feb 2013 10:50:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E16E321C048; Fri, 1 Feb 2013 10:49:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DD22321C049 for ; Fri, 1 Feb 2013 10:49:52 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AA05933DCB2 for ; Fri, 1 Feb 2013 10:49:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5DD25E4095 for ; Fri, 1 Feb 2013 10:49:49 +0000 (UTC) From: "Sven Eden" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sven Eden" Message-ID: <1359656238.34e1d52dfebe0758f3433ee5c7c2c625ca9b5411.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses-debug.h ufed-curses-types.c ufed-curses-types.h ufed-debug.h ufed-types.c ufed-types.h X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 34e1d52dfebe0758f3433ee5c7c2c625ca9b5411 X-VCS-Branch: master Date: Fri, 1 Feb 2013 10:49:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 1f669d65-b6bb-4a0a-b268-e13106fde331 X-Archives-Hash: 7d68f6a2e2f6c0c5b5d5e3c8e6663266 commit: 34e1d52dfebe0758f3433ee5c7c2c625ca9b5411 Author: Sven Eden gmx de> AuthorDate: Thu Jan 31 18:17:18 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Thu Jan 31 18:17:18 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=34e1d52d Renamed ufed-curses-debug.h, ufed-types.c and ufed-types.h to ufed-curses-debug.h, ufed-curses-types.c and ufed-curses-types.h to match the naming of the other files --- ufed-debug.h => ufed-curses-debug.h | 0 ufed-types.c => ufed-curses-types.c | 69 ++++++++++++++++++++++++++++------- ufed-types.h => ufed-curses-types.h | 28 ++++++++++++-- 3 files changed, 79 insertions(+), 18 deletions(-) diff --git a/ufed-debug.h b/ufed-curses-debug.h similarity index 100% rename from ufed-debug.h rename to ufed-curses-debug.h diff --git a/ufed-types.c b/ufed-curses-types.c similarity index 85% rename from ufed-types.c rename to ufed-curses-types.c index 694ea29..7b208fa 100644 --- a/ufed-types.c +++ b/ufed-curses-types.c @@ -4,7 +4,7 @@ * Created on: 28.01.2013 * Author: Sven Eden */ -#include "ufed-types.h" +#include "ufed-curses-types.h" #include "ufed-curses.h" #include #include @@ -61,9 +61,9 @@ sFlag* addFlag (sFlag** root, const char* name, int line, int ndesc, const char ERROR_EXIT(-1, "Unable to allocate %lu bytes for %d sDesc_ structs\n", sizeof(sDesc) * ndesc, ndesc) - newFlag->forced = false; + newFlag->globalForced = false; + newFlag->globalMasked = false; newFlag->listline = line; - newFlag->masked = false; newFlag->name = strdup(name); newFlag->ndesc = ndesc; newFlag->next = NULL; @@ -128,9 +128,9 @@ size_t addFlagDesc (sFlag* flag, const char* pkg, const char* desc, const char s // Set flag mask and force status if this is a global and masked/forced description if (flag->desc[idx].isGlobal && ('+' == flag->desc[idx].stateMasked)) - flag->masked = true; + flag->globalMasked = true; if (flag->desc[idx].isGlobal && ('+' == flag->desc[idx].stateForced)) - flag->forced = true; + flag->globalForced = true; // Determine width: result += (flag->desc[idx].pkg ? strlen(flag->desc[idx].pkg) : 0) @@ -155,15 +155,7 @@ void addLineStats (const sFlag* flag, sListStats* stats) { if (flag && stats) { for (int i = 0; i < flag->ndesc; ++i) { - // Masked is true if the flag is globally masked/forced - // and the description is not explicitly unmasked/unforced, - // or if the description is explicitly masked/forced. - if ( ('+' == flag->desc[i].stateMasked) - || ('+' == flag->desc[i].stateForced) - || ( (' ' == flag->desc[i].stateMasked) - && flag->masked ) - || ( (' ' == flag->desc[i].stateForced) - && flag->forced ) ) { + if ( isDescMasked(flag, i) ) { if (flag->desc[i].isInstalled) ++stats->lineCountMaskedInstalled; else @@ -252,6 +244,27 @@ int getFlagHeight (const sFlag* flag) } +/** @brief return true if a specific description line is force enabled + * If @a flag is NULL, the result will be false. + * @param[in] flag pointer to the flag to check. + * @param[in] idx index of the description line to check. + * @return true if the specific flag (global or local) is forced + */ +bool isDescForced(const sFlag* flag, int idx) +{ + bool result = false; + + if (flag && (idx < flag->ndesc)) { + if ( ('+' == flag->desc[idx].stateForced) + || ( (' ' == flag->desc[idx].stateForced) + && flag->globalForced ) ) + result = true; + } + + return result; +} + + /** @brief return true if the flag description @a idx is ok to display. * If @a flag is NULL, the result will be false. * @param[in] flag pointer to the flag to check. @@ -278,6 +291,34 @@ bool isDescLegal (const sFlag* flag, int idx) return result; } + +/** @brief return true if a specific description line is masked + * If @a flag is NULL, the result will be false. + * @param[in] flag pointer to the flag to check. + * @param[in] idx index of the description line to check. + * @return true if the specific flag (global or local) is masked + */ +bool isDescMasked(const sFlag* flag, int idx) +{ + bool result = false; + + // Note: Masked is true if the flag is globally masked/forced + // and the description is not explicitly unmasked/unforced, + // or if the description is explicitly masked/forced. + if (flag && (idx < flag->ndesc)) { + if ( ('+' == flag->desc[idx].stateMasked) + || ('+' == flag->desc[idx].stateForced) + || ( (' ' == flag->desc[idx].stateMasked) + && flag->globalMasked ) + || ( (' ' == flag->desc[idx].stateForced) + && flag->globalForced ) ) + result = true; + } + + return result; +} + + /** @brief return true if this flag has at least one line to display. * This method checks the flag and its description line(s) * settings against the globally active filters. diff --git a/ufed-types.h b/ufed-curses-types.h similarity index 88% rename from ufed-types.h rename to ufed-curses-types.h index 9953b6a..cb02e85 100644 --- a/ufed-types.h +++ b/ufed-curses-types.h @@ -9,11 +9,29 @@ #define UFED_TYPES_H_INCLUDED 1 #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include -#include "ufed-debug.h" +#include "ufed-curses-debug.h" + +#ifdef HAVE_STDINT_H +# include +// TODO : else branch +#endif + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + +#ifndef bool +# ifdef HAVE__BOOL +# define bool _Bool +# else +# define bool int +# endif +#endif + /* ============= * === enums === @@ -94,9 +112,9 @@ typedef struct sDesc_ { typedef struct sFlag_ { int currline; //!< The current line on the screen this flag starts sDesc* desc; //!< variable array of sDesc structs - bool forced; //!< true if the first global description is force enabled. + bool globalForced; //!< true if the first global description is force enabled. + bool globalMasked; //!< true if the first global description is mask enabled. int listline; //!< The fixed line within the full list this flag starts - bool masked; //!< true if the first global description is mask enabled. char* name; //!< Name of the flag or NULL for help lines int ndesc; //!< number of description lines struct @@ -149,7 +167,9 @@ size_t addFlagDesc (sFlag* flag, const char* pkg, const char* desc, const char void addLineStats (const sFlag* flag, sListStats* stats); void destroyFlag (sFlag** root, sFlag** flag); int getFlagHeight(const sFlag* flag); +bool isDescForced (const sFlag* flag, int idx); bool isDescLegal (const sFlag* flag, int idx); +bool isDescMasked (const sFlag* flag, int idx); bool isFlagLegal (const sFlag* flag); #endif /* UFED_TYPES_H_INCLUDED */