diff options
author | AlejandroColomar <colomar.6.4.3@gmail.com> | 2018-11-22 10:57:57 +0100 |
---|---|---|
committer | AlejandroColomar <colomar.6.4.3@gmail.com> | 2018-11-22 10:57:57 +0100 |
commit | 3056ae54d89cf33bf65633359369458961f4cbad (patch) | |
tree | 962d2c547b5e8efe5cb0f5d9123fc618f5c40a2a | |
parent | 05ad46d670916e7885bcdc92a5cab72635e750a0 (diff) |
Use libalx as submodule
-rw-r--r-- | libalx/COPYING.txt | 352 | ||||
-rw-r--r-- | libalx/Makefile | 19 | ||||
-rw-r--r-- | libalx/inc/alx_cmp.h | 27 | ||||
-rw-r--r-- | libalx/inc/alx_file.h | 27 | ||||
-rw-r--r-- | libalx/inc/alx_input.h | 64 | ||||
-rw-r--r-- | libalx/inc/alx_input.hpp | 75 | ||||
-rw-r--r-- | libalx/inc/alx_mask.h | 33 | ||||
-rw-r--r-- | libalx/inc/alx_math.h | 43 | ||||
-rw-r--r-- | libalx/inc/alx_ncur.h | 99 | ||||
-rw-r--r-- | libalx/inc/alx_ncur.hpp | 113 | ||||
-rw-r--r-- | libalx/inc/alx_seed.h | 33 | ||||
-rw-r--r-- | libalx/src/alx_cmp.c | 45 | ||||
-rw-r--r-- | libalx/src/alx_file.c | 100 | ||||
-rw-r--r-- | libalx/src/alx_input.c | 268 | ||||
-rw-r--r-- | libalx/src/alx_mask.c | 31 | ||||
-rw-r--r-- | libalx/src/alx_math.c | 54 | ||||
-rw-r--r-- | libalx/src/alx_ncur.c | 672 | ||||
-rw-r--r-- | libalx/src/alx_seed.c | 49 | ||||
-rw-r--r-- | libalx/tmp/Makefile | 106 |
19 files changed, 0 insertions, 2210 deletions
diff --git a/libalx/COPYING.txt b/libalx/COPYING.txt deleted file mode 100644 index 6d41bc3..0000000 --- a/libalx/COPYING.txt +++ /dev/null @@ -1,352 +0,0 @@ - NOTE! The GPL below is copyrighted by the Free Software - Foundation, but the instance of code that it refers to (libalx) - is copyrighted by me who actually wrote it. - - Also note that the only valid version of the GPL is _this_ particular - version of the license (ie v2, not v2.2 or v3.x or whatever), unless - explicitly otherwise stated. - - Alejandro Colomar - ----------------------------------------- - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/libalx/Makefile b/libalx/Makefile deleted file mode 100644 index e0096c4..0000000 --- a/libalx/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# -*- MakeFile -*- - -# MACRO = substitute with this - -# directories - -TMP_DIR = $(LIBALX_DIR)/tmp/ - - -# target: dependencies -# action - -all: - $(Q)cd $(TMP_DIR) && $(MAKE) && cd .. - - -clean: - $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd .. - @echo "Clean libalx" diff --git a/libalx/inc/alx_cmp.h b/libalx/inc/alx_cmp.h deleted file mode 100644 index 6844d73..0000000 --- a/libalx/inc/alx_cmp.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************
- * NO COPYRIGHT FOR THIS FILE. FREE FOR ALL *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_CMP_H
- # define ALX_CMP_H
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- int compare_int64 (const void *a, const void *b);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_cmp.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_file.h b/libalx/inc/alx_file.h deleted file mode 100644 index 352d422..0000000 --- a/libalx/inc/alx_file.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_FILE_H
- # define ALX_FILE_H
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
-void alx_snprint_file (char *dest, int destsize, const char *filepath);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_file.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_input.h b/libalx/inc/alx_input.h deleted file mode 100644 index 32fe322..0000000 --- a/libalx/inc/alx_input.h +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_INPUT_H
- # define ALX_INPUT_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <math.h>
- #include <stdarg.h>
- #include <stdbool.h>
- #include <stdint.h>
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- int alx_sscan_dbl (double *dest,
- double m,
- double def,
- double M,
- const char *str);
-
- int alx_sscan_int (int64_t *dest,
- double m,
- int64_t def,
- double M,
- const char *str);
-
- int alx_sscan_fname (const char *fpath,
- char *fname,
- bool exist,
- const char *str);
-
- double alx_getdbl (double m,
- double def,
- double M,
- const char *title,
- const char *help);
-
- int64_t alx_getint (double m,
- int64_t def,
- double M,
- const char *title,
- const char *help);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_input.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_input.hpp b/libalx/inc/alx_input.hpp deleted file mode 100644 index 7fa6a8a..0000000 --- a/libalx/inc/alx_input.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_INPUT_HPP
- # define ALX_INPUT_HPP
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- #include <math.h>
- #include <stdarg.h>
- #include <stdbool.h>
- #include <stdint.h>
-
-
-/******************************************************************************
- ******* C wrapper ************************************************************
- ******************************************************************************/
-extern "C" {
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- int alx_sscan_dbl (double *dest,
- double m,
- double def,
- double M,
- const char *str);
-
- int alx_sscan_int (int64_t *dest,
- double m,
- int64_t def,
- double M,
- const char *str);
-
- int alx_sscan_fname (const char *fpath,
- char *fname,
- bool exist,
- const char *str);
-
- double alx_getdbl (double m,
- double def,
- double M,
- const char *title,
- const char *help);
-
- int64_t alx_getint (double m,
- int64_t def,
- double M,
- const char *title,
- const char *help);
-
-
-/******************************************************************************
- ******* C wrapper ************************************************************
- ******************************************************************************/
-} /* extern "C" */
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_input.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_mask.h b/libalx/inc/alx_mask.h deleted file mode 100644 index 9230013..0000000 --- a/libalx/inc/alx_mask.h +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************
- * NO COPYRIGHT FOR THIS FILE. FREE FOR ALL *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_MASK_H
- # define ALX_MASK_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- #include <stdint.h>
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- uint64_t alx_maskgen (int64_t l);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_mask.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_math.h b/libalx/inc/alx_math.h deleted file mode 100644 index 69ae00a..0000000 --- a/libalx/inc/alx_math.h +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************** - * NO COPYRIGHT FOR THIS FILE. FREE FOR ALL * - ******************************************************************************/ - - -/****************************************************************************** - ******* include guard ******************************************************** - ******************************************************************************/ -# ifndef ALX_MATH_H - # define ALX_MATH_H - - -/****************************************************************************** - ******* headers ************************************************************** - ******************************************************************************/ - #include <math.h> - #include <stdint.h> - - -/****************************************************************************** - ******* functions ************************************************************ - ******************************************************************************/ - /* - * Factorial - */ -double alx_fact (int64_t n); - - /* - * Binomial coefficient (a b): --!!! a > b !!!-- - * - Bugs: If !(a > b), returns 1. - */ -double alx_bin_coef (int64_t a, int64_t b); - - -/****************************************************************************** - ******* include guard ******************************************************** - ******************************************************************************/ -# endif /* alx_math.h */ - - -/****************************************************************************** - ******* end of file ********************************************************** - ******************************************************************************/ diff --git a/libalx/inc/alx_ncur.h b/libalx/inc/alx_ncur.h deleted file mode 100644 index 004105d..0000000 --- a/libalx/inc/alx_ncur.h +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_NCUR_H
- # define ALX_NCUR_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <stdint.h>
-
-/* Packages ------------------------------------------------------------------*/
- #include <ncurses.h>
-
-
-/******************************************************************************
- ******* structs **************************************************************
- ******************************************************************************/
- struct Alx_Menu {
- int r;
- int c;
- char *t;
- };
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- void alx_start_curses (void);
- void alx_pause_curses (void);
- void alx_resume_curses (void);
- void alx_end_curses (void);
- void alx_win_del (WINDOW *win);
-
- int alx_menu (int h,
- int w,
- int N,
- struct Alx_Menu mnu[N],
- const char *str);
-
- int alx_menu_2 (WINDOW *win,
- int N,
- struct Alx_Menu mnu[N],
- const char *str);
-
- double alx_w_getdbl (int w,
- int r,
- const char *title,
- double m,
- double def,
- double M,
- const char *help);
-
- int64_t alx_w_getint (int w,
- int r,
- const char *title,
- double m,
- int64_t def,
- double M,
- const char *help);
-
- void alx_w_getstr (char *dest,
- int destsize,
- int w,
- int r,
- const char *title,
- const char *help);
-
- void alx_w_getfname (const char *fpath,
- char *fname,
- bool exist,
- int w,
- int r,
- const char *title,
- const char *help);
-
- void alx_ncur_prn_title (WINDOW *win,
- const char *title);
-
- void alx_ncur_prn_subtitle (WINDOW *win,
- const char *subtitle);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_ncur.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_ncur.hpp b/libalx/inc/alx_ncur.hpp deleted file mode 100644 index 676b64b..0000000 --- a/libalx/inc/alx_ncur.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_NCUR_HPP
- # define ALX_NCUR_HPP
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- /* int64_t */
- #include <cstdint>
-
-/* Packages ------------------------------------------------------------------*/
- /* WINDOW */
- #include <ncurses.h>
-
-
-/******************************************************************************
- ******* C wrapper ************************************************************
- ******************************************************************************/
-extern "C" {
-
-
-/******************************************************************************
- ******* structs **************************************************************
- ******************************************************************************/
- struct Alx_Menu {
- int r;
- int c;
- char *t;
- };
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- void alx_start_curses (void);
- void alx_pause_curses (void);
- void alx_resume_curses (void);
- void alx_end_curses (void);
- void alx_win_del (WINDOW *win);
-
- int alx_menu (int h,
- int w,
- int N,
- struct Alx_Menu mnu[],
- const char *str);
-
- int alx_menu_2 (WINDOW *win,
- int N,
- struct Alx_Menu mnu[],
- const char *str);
-
- double alx_w_getdbl (int w,
- int r,
- const char *title,
- double m,
- double def,
- double M,
- const char *help);
-
- int64_t alx_w_getint (int w,
- int r,
- const char *title,
- double m,
- int64_t def,
- double M,
- const char *help);
-
- void alx_w_getstr (char *dest,
- int destsize,
- int w,
- int r,
- const char *title,
- const char *help);
-
- void alx_w_getfname (const char *fpath,
- char *fname,
- bool exist,
- int w,
- int r,
- const char *title,
- const char *help);
-
- void alx_ncur_prn_title (WINDOW *win,
- const char *title);
-
- void alx_ncur_prn_subtitle (WINDOW *win,
- const char *subtitle);
-
-
-/******************************************************************************
- ******* C wrapper ************************************************************
- ******************************************************************************/
-} /* extern "C" */
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* alx_ncur.hpp */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/inc/alx_seed.h b/libalx/inc/alx_seed.h deleted file mode 100644 index 161283d..0000000 --- a/libalx/inc/alx_seed.h +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************
- * Robert Jenkins' 96 bit Mix Function *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef ALX_SEED_H
- # define ALX_SEED_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- #include <stdint.h>
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
- uint32_t seedf (uint32_t a, uint32_t b, uint32_t c);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* seed.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/src/alx_cmp.c b/libalx/src/alx_cmp.c deleted file mode 100644 index e851eee..0000000 --- a/libalx/src/alx_cmp.c +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************
- * NO COPYRIGHT FOR THIS FILE. FREE FOR ALL *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * * Standard * * * * * *
- * * * * * * * * * */
- #include <stdint.h>
-
-/* * * * * * * * * *
- * * * Other * * * * * * *
- * * * * * * * * * */
- #include "alx_cmp.h"
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
- /*
- * Comparison function. Receives two items under comparison.
- * return int
- */
-int compare_int64 (const void *a, const void *b)
-{
- int r;
-
- if (*(int64_t *)a < *(int64_t *)b) {
- r = -1;
- } else if (*(int64_t *)a > *(int64_t *)b) {
- r = 1;
- } else if (*(int64_t *)a == *(int64_t *)b) {
- r = 0;
- }
-
- return r;
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/src/alx_file.c b/libalx/src/alx_file.c deleted file mode 100644 index 26ab468..0000000 --- a/libalx/src/alx_file.c +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * * Standard * * * * * *
- * * * * * * * * * */
- #include <errno.h>
- #include <stdbool.h>
- #include <stdint.h>
- #include <stdio.h>
-
-/* * * * * * * * * *
- * * * Other * * * * * * *
- * * * * * * * * * */
- #include "alx_file.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define BUFF_SIZE_TEXT (1048576)
-
-#if defined OS_LINUX
- # define BEGINNING "\n┌──────────────────────────────────────────────────────────────────────────────┐\n"
- # define ENDING "└──────────────────────────────────────────────────────────────────────────────┘\n\n"
-#elif defined OS_WIN
- # define BEGINNING "\n________________________________________________________________________________\n"
- # define ENDING "________________________________________________________________________________\n\n"
-#endif
-
- # define ERR_FPTR_MSG "¡ FILE error !"
- # define ERR_FSIZE_MSG "¡ FILE is too big !"
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-void alx_snprint_file (char *dest, int destsize, const char *filepath)
-{
- char buff [BUFF_SIZE_TEXT];
- FILE *fp;
-
- /* Open file */
- fp = fopen(filepath, "r");
-
-#if 0
- /* Implemented using getc instead of fread */
- char *str;
- int64_t c;
-
- if (fp) {
- str = buff;
- while (((c = getc(fp)) != EOF) && str < BUFF_SIZE_TEXT) {
- sprintf(p, "%c", (char)c);
- str++;
- }
- fclose(fp);
- } else {
- puts(ERR_FPTR_MSG);
- printf(" errno = %i;\n", errno);
- }
-#else
- long len;
- if (fp) {
- /* File lenght */
- fseek(fp, 0, SEEK_END);
- len = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- /* Read file into buff and append '\0' */
- if (len < BUFF_SIZE_TEXT) {
- fread(buff, sizeof(char), len, fp);
- buff[len] = '\0';
- } else {
- /* Prevent buffer overflow */
- puts(ERR_FSIZE_MSG);
- }
-
- /* Close file */
- fclose(fp);
- } else {
- /* File error */
- puts(ERR_FPTR_MSG);
- printf(" errno = %i;\n", errno);
- }
-#endif
-
- /* Print into dest */
- snprintf(dest, destsize, "%s", buff);
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/src/alx_input.c b/libalx/src/alx_input.c deleted file mode 100644 index 9761932..0000000 --- a/libalx/src/alx_input.c +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <inttypes.h>
- #include <stdarg.h>
- #include <stdbool.h>
- #include <stdio.h>
-
-/* libalx --------------------------------------------------------------------*/
- #include "alx_input.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define BUFF_SIZE (1024)
-
- # define MAX_TRIES (2)
-
- # define ERR_OK (0)
- # define ERR_RANGE (1)
- # define ERR_SSCANF (2)
- # define ERR_FPTR (3)
- # define ERR_FGETS (4)
-
- # define ERR_RANGE_MSG "¡ Number is out of range !"
- # define ERR_SSCANF_MSG "¡ sscanf() error !"
- # define ERR_FPTR_MSG "¡ FILE error !"
- # define ERR_FGETS_MSG "¡ fgets() error !"
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-static double loop_getdbl (double m, double def, double M);
-static int64_t loop_getint (double m, int64_t def, double M);
-static void manage_error (int err);
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
- /*
- * Scan a double in the range [m, M].
- * return: 0 if correct
- * non 0 if there is an error
- */
-int alx_sscan_dbl (double *dest, double m, double def, double M, const char *str)
-{
- int err;
-
- if (sscanf(str, " %lf", dest) != 1) {
- err = ERR_SSCANF;
- } else if ((*dest < m) || (*dest > M)) {
- err = ERR_RANGE;
- } else {
- err = ERR_OK;
- }
-
- if (err) {
- *dest = def;
- }
-
- return err;
-}
-
- /*
- * Scan an int64_t in the range [m, M].
- * return: 0 if correct
- * non 0 if there is an error
- */
-int alx_sscan_int (int64_t *dest, double m, int64_t def, double M, const char *str)
-{
- int err;
-
- if (sscanf(str, " %"SCNi64"", dest) != 1) {
- err = ERR_SSCANF;
- } else if ((*dest < m) || (*dest > M)) {
- err = ERR_RANGE;
- } else {
- err = ERR_OK;
- }
-
- if (err) {
- *dest = def;
- }
-
- return err;
-}
-
- /*
- * Scan a file name in fpath.
- * return: 0 if correct
- * non 0 if there is an error
- */
-int alx_sscan_fname (const char *fpath, char *fname, bool exist, const char *str)
-{
- char buff [FILENAME_MAX];
- char file_path [FILENAME_MAX];
- int err;
- FILE *fp;
-
- if (sscanf(str, " %s ", buff) != 1) {
- err = ERR_SSCANF;
- } else {
- snprintf(file_path, FILENAME_MAX, "%s%s", fpath, buff);
-
- fp = fopen(file_path, "r");
-
- if (exist) {
- if (fp == NULL) {
- err = ERR_FPTR;
- } else {
- err = ERR_OK;
- fclose(fp);
- }
- } else {
- if (fp == NULL) {
- err = ERR_OK;
- } else {
- err = ERR_FPTR;
- fclose(fp);
- }
- }
- }
-
- if (!err) {
- snprintf(fname, FILENAME_MAX, "%s", buff);
- }
-
- return err;
-}
-
- /*
- * Ask for a double in the range [m, M].
- *
- * If the user enters a non valid number, it repeats to ask for
- * the number two more times. After that, it uses the default
- * value.
- */
-double alx_getdbl (double m, double def, double M,
- const char *title, const char *help)
-{
- double R;
-
- if (title != NULL) {
- puts(title);
- }
- if (help == NULL) {
- printf("Introduce a real number [%lf U %lf] (default %lf):...\t", m, M, def);
- } else {
- puts(help);
- }
-
- R = loop_getdbl(m, def, M);
-
- return R;
-}
-
- /*
- * Ask for an int64_t in the range [m, M].
- *
- * If the user enters a non valid number, it repeats to ask for
- * the number two more times. After that, it uses the default
- * value.
- */
-int64_t alx_getint (double m, int64_t def, double M,
- const char *title, const char *help)
-{
- int64_t Z;
-
- if (title != NULL) {
- puts(title);
- }
- if (help == NULL) {
- printf("Introduce an integer number [%lf U %lf] (default %"PRIi64"):...\t", m, M, def);
- } else {
- puts(help);
- }
-
- Z = loop_getint(m, def, M);
-
- return Z;
-}
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-static double loop_getdbl (double m, double def, double M)
-{
- int i;
- char buff [BUFF_SIZE];
- char *x;
- double R;
- int err;
-
- for (i = 0; i < MAX_TRIES; i++) {
- x = fgets(buff, BUFF_SIZE, stdin);
-
- if (x == NULL) {
- err = ERR_FGETS;
- } else {
- err = alx_sscan_dbl(&R, m, def, M, buff);
- }
-
- if (err) {
- manage_error(err);
- } else {
- break;
- }
- }
-
- return R;
-}
-
-static int64_t loop_getint (double m, int64_t def, double M)
-{
- int i;
- char buff [BUFF_SIZE];
- char *x;
- int64_t Z;
- int err;
-
- for (i = 0; i < MAX_TRIES; i++) {
- x = fgets(buff, BUFF_SIZE, stdin);
-
- if (x == NULL) {
- err = ERR_FGETS;
- } else {
- err = alx_sscan_int(&Z, m, def, M, buff);
- }
-
- if (err) {
- manage_error(err);
- } else {
- break;
- }
- }
-
- return Z;
-}
-
-static void manage_error (int err)
-{
- switch (err) {
- case ERR_RANGE:
- puts(ERR_RANGE_MSG);
- break;
- case ERR_SSCANF:
- puts(ERR_SSCANF_MSG);
- break;
- case ERR_FGETS:
- puts(ERR_FGETS_MSG);
- break;
- }
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/src/alx_mask.c b/libalx/src/alx_mask.c deleted file mode 100644 index 49b4cb2..0000000 --- a/libalx/src/alx_mask.c +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************
- * NO COPYRIGHT FOR THIS FILE. FREE FOR ALL *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * * Standard * * * * * *
- * * * * * * * * * */
- #include <stdint.h>
-
-/* * * * * * * * * *
- * * * Other * * * * * * *
- * * * * * * * * * */
- #include "alx_mask.h"
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-uint64_t alx_maskgen (int64_t l)
-{
- return (1LL << l);
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/src/alx_math.c b/libalx/src/alx_math.c deleted file mode 100644 index 1d11d59..0000000 --- a/libalx/src/alx_math.c +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * NO COPYRIGHT FOR THIS FILE. FREE FOR ALL * - ******************************************************************************/ - - -/****************************************************************************** - ******* headers ************************************************************** - ******************************************************************************/ -/* * * * * * * * * * - * * * Standard * * * * * * - * * * * * * * * * */ - #include <stdint.h> - -/* * * * * * * * * * - * * * Other * * * * * * * - * * * * * * * * * */ - #include "alx_math.h" - - -/****************************************************************************** - ******* main ***************************************************************** - ******************************************************************************/ - /* - * Factorial - */ -double alx_fact (int64_t n) -{ - if (n < 1) { - return 1; - } else { - return n * alx_fact(n - 1); - } -} - - /* - * Binomial coefficient (a b): --!!! a > b !!!-- - * - Bugs: If !(a > b), returns 1. - */ -double alx_bin_coef (int64_t a, int64_t b) -{ - int64_t i = 1; - double c = 1; - - while (a > b) { - c = c * a-- / i++; - } - - return c; -} - - -/****************************************************************************** - ******* end of file ********************************************************** - ******************************************************************************/ diff --git a/libalx/src/alx_ncur.c b/libalx/src/alx_ncur.c deleted file mode 100644 index 1ba5c3c..0000000 --- a/libalx/src/alx_ncur.c +++ /dev/null @@ -1,672 +0,0 @@ -/******************************************************************************
- * Copyright (C) 2017 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <inttypes.h>
- #include <stdbool.h>
- #include <stdio.h>
- /* strlen() */
- #include <string.h>
- /* wchar_t */
- #include <wchar.h>
-
-/* Packages ------------------------------------------------------------------*/
- #include <ncurses.h>
-
-/* libalx --------------------------------------------------------------------*/
- #include "alx_input.h"
-
- #include "alx_ncur.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define BUFF_SIZE (1024)
-
- # define MAX_TRIES (2)
-
- # define ERR_OK (0)
- # define ERR_RANGE (1)
- # define ERR_SSCANF (2)
- # define ERR_FPTR (3)
- # define ERR_FGETS (4)
- # define ERR_GETSTR (5)
-
- # define ERR_RANGE_MSG "¡ Number is out of range !"
- # define ERR_SSCANF_MSG "¡ sscanf() error !"
- # define ERR_FPTR_MSG "¡ FILE error !"
- # define ERR_GETSTR_MSG "¡ wgetstr() error !"
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-static void alx_ncur_prn_menu (WINDOW *win,
- int N, struct Alx_Menu mnu[N]);
-static int alx_ncur_usr_sel (WINDOW *win,
- int N, struct Alx_Menu mnu[N]);
-static double loop_w_getdbl (WINDOW *win,
- double m, double def, double M);
-static int64_t loop_w_getint (WINDOW *win,
- double m, int64_t def, double M);
-static void loop_w_getstr (char *dest, int destsize, WINDOW *win);
-
-static void loop_w_getfname (const char *fpath, char *fname, bool exist,
- WINDOW *win);
-static void manage_w_error (WINDOW *win, int err);
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-void alx_start_curses (void)
-{
- initscr();
- nonl();
- cbreak();
- noecho();
- keypad(stdscr, true);
-
- if (has_colors()) {
- start_color();
- use_default_colors();
- }
-// mousemask(BUTTON4_PRESSED | BUTTON2_PRESSED, NULL);
-}
-
-void alx_pause_curses (void)
-{
- def_prog_mode();
- endwin();
-}
-
-void alx_resume_curses (void)
-{
- fflush(stdout);
- reset_prog_mode();
-}
-
-void alx_end_curses (void)
-{
- clear();
- refresh();
- endwin();
-}
-
-void alx_win_del (WINDOW *win)
-{
- /* Delete window */
- wbkgd(win, 0);
- wclear(win);
- wrefresh(win);
- delwin(win);
-}
-
-int alx_menu (int h, int w,
- int N, struct Alx_Menu mnu[N], const char *title)
-{
- /* Dimensions */
- WINDOW *win;
- int r;
- int c;
- r = 1;
- c = (80 - w) / 2;
- win = newwin(h, w, r, c);
-
- /* Input */
- int i;
- i = alx_menu_2(win, N, mnu, title);
-
- /* Delete window */
- alx_win_del(win);
-
- return i;
-}
-
-int alx_menu_2 (WINDOW *win,
- int N, struct Alx_Menu mnu[N], const char *title)
-{
- /* Activate keypad, and don't echo input */
- keypad(win, true);
- noecho();
-
- /* Print box, title and menu items */
- box(win, 0, 0);
- alx_ncur_prn_title(win, title);
- alx_ncur_prn_menu(win, N, mnu);
-
- /* Input */
- int i;
- i = alx_ncur_usr_sel(win, N, mnu);
-
- return i;
-}
-
-double alx_w_getdbl (int w, int r, const char *title,
- double m, double def, double M,
- const char *help)
-{
- /* Dimensions */
- WINDOW *win1;
- int h1;
- int w1;
- int r1;
- int c1;
- WINDOW *win2;
- int h2;
- int w2;
- int r2;
- int c2;
- WINDOW *win3;
- int h3;
- int w3;
- int r3;
- int c3;
- h1 = 3;
- w1 = w;
- r1 = r;
- c1 = (80 - w) / 2;
- h2 = 1;
- w2 = w1 - 4;
- r2 = r1 + 3;
- c2 = c1 + 2;
- h3 = 1;
- w3 = w1 - 2;
- r3 = r1 + 1;
- c3 = c1 + 1;
-
- /* Box & title */
- win1 = newwin(h1, w1, r1, c1);
- wbkgd(win1, A_REVERSE);
- box(win1, 0, 0);
- alx_ncur_prn_title(win1, title);
- wrefresh(win1);
-
- /* Help */
- win2 = newwin(h2, w2, r2, c2);
- if (help == NULL) {
- wprintw(win2, "Introduce a real number [%lf U %lf] (default %lf)", m, M, def);
- } else {
- wprintw(win2, "%s", help);
- }
- wrefresh(win2);
-
- /* Input */
- double R;
- win3 = newwin(h3, w3, r3, c3);
- wbkgd(win3, A_REVERSE);
- wrefresh(win3);
- R = loop_w_getdbl(win3, m, def, M);
-
- /* Delete window */
- alx_win_del(win3);
- alx_win_del(win2);
- alx_win_del(win1);
-
- return R;
-}
-
-int64_t alx_w_getint (int w, int r, const char *title,
- double m, int64_t def, double M,
- const char *help)
-{
- /* Dimensions */
- WINDOW *win1;
- int h1;
- int w1;
- int r1;
- int c1;
- WINDOW *win2;
- int h2;
- int w2;
- int r2;
- int c2;
- WINDOW *win3;
- int h3;
- int w3;
- int r3;
- int c3;
- h1 = 3;
- w1 = w;
- r1 = r;
- c1 = (80 - w) / 2;
- h2 = 1;
- w2 = w1 - 4;
- r2 = r1 + 3;
- c2 = c1 + 2;
- h3 = 1;
- w3 = w1 - 2;
- r3 = r1 + 1;
- c3 = c1 + 1;
-
- /* Box & title */
- win1 = newwin(h1, w1, r1, c1);
- wbkgd(win1, A_REVERSE);
- box(win1, 0, 0);
- alx_ncur_prn_title(win1, title);
- wrefresh(win1);
-
- /* Help */
- win2 = newwin(h2, w2, r2, c2);
- if (help == NULL) {
- wprintw(win2, "Introduce an integer number [%lf U %lf] (default %"PRIi64")", m, M, def);
- } else {
- wprintw(win2, "%s", help);
- }
- wrefresh(win2);
-
- /* Input */
- int Z;
- win3 = newwin(h3, w3, r3, c3);
- wbkgd(win3, A_REVERSE);
- wrefresh(win3);
- Z = loop_w_getint(win3, m, def, M);
-
- /* Delete window */
- alx_win_del(win3);
- alx_win_del(win2);
- alx_win_del(win1);
-
- return Z;
-}
-
-void alx_w_getstr (char *dest, int destsize,
- int w, int r, const char *title,
- const char *help)
-{
- /* Dimensions */
- WINDOW *win1;
- int h1;
- int w1;
- int r1;
- int c1;
- h1 = 3;
- w1 = w;
- r1 = r;
- c1 = (80 - w) / 2;
- WINDOW *win2;
- int h2;
- int w2;
- int r2;
- int c2;
- h2 = 1;
- w2 = w1 - 4;
- r2 = r1 + 3;
- c2 = c1 + 2;
- WINDOW *win3;
- int h3;
- int w3;
- int r3;
- int c3;
- h3 = 1;
- w3 = w1 - 2;
- r3 = r1 + 1;
- c3 = c1 + 1;
-
- /* Box & title */
- win1 = newwin(h1, w1, r1, c1);
- wbkgd(win1, A_REVERSE);
- box(win1, 0, 0);
- alx_ncur_prn_title(win1, title);
- wrefresh(win1);
-
- /* Help */
- win2 = newwin(h2, w2, r2, c2);
- if (help == NULL) {
- waddstr(win2, "Introduce a string");
- } else {
- wprintw(win2, "%s", help);
- }
- wrefresh(win2);
-
- /* Input */
- win3 = newwin(h3, w3, r3, c3);
- wbkgd(win3, A_REVERSE);
- wrefresh(win3);
- loop_w_getstr(dest, destsize, win3);
-
- /* Delete window */
- alx_win_del(win3);
- alx_win_del(win2);
- alx_win_del(win1);
-}
-
-void alx_w_getfname (const char *fpath, char *fname, bool exist,
- int w, int r, const char *title,
- const char *help)
-{
- /* Dimensions */
- WINDOW *win1;
- int h1;
- int w1;
- int r1;
- int c1;
- WINDOW *win2;
- int h2;
- int w2;
- int r2;
- int c2;
- WINDOW *win3;
- int h3;
- int w3;
- int r3;
- int c3;
- h1 = 3;
- w1 = w;
- r1 = r;
- c1 = (80 - w) / 2;
- h2 = 1;
- w2 = w1 - 4;
- r2 = r1 + 3;
- c2 = c1 + 2;
- h3 = 1;
- w3 = w1 - 2;
- r3 = r1 + 1;
- c3 = c1 + 1;
-
- /* Box & title */
- win1 = newwin(h1, w1, r1, c1);
- wbkgd(win1, A_REVERSE);
- box(win1, 0, 0);
- alx_ncur_prn_title(win1, title);
- wrefresh(win1);
-
- /* Help */
- win2 = newwin(h2, w2, r2, c2);
- if (help == NULL) {
- waddstr(win2, "Introduce a file name");
- } else {
- wprintw(win2, "%s", help);
- }
- wrefresh(win2);
-
- /* Input */
- win3 = newwin(h3, w3, r3, c3);
- wbkgd(win3, A_REVERSE);
- wrefresh(win3);
- loop_w_getfname(fpath, fname, exist, win3);
-
- /* Delete window */
- alx_win_del(win3);
- alx_win_del(win2);
- alx_win_del(win1);
-}
-
-void alx_ncur_prn_title (WINDOW *win, const char *title)
-{
- /* Find size of window */
- int h;
- int w;
- getmaxyx(win, h, w);
-
- /* Find length of title */
- int len;
- len = strlen(title);
-
- /* Print title centered */
- mvwaddch(win, 0, (w - (len + 2))/2 - 1, ACS_RTEE);
- wprintw(win, " %s ", title);
- waddch(win, ACS_LTEE);
-}
-
-void alx_ncur_prn_subtitle (WINDOW *win, const char *subtitle)
-{
- /* Find size of window */
- int h;
- int w;
- getmaxyx(win, h, w);
-
- /* Find length of title */
- int len;
- len = strlen(subtitle);
-
- /* Print subtitle centered */
- mvwaddch(win, h - 1, (w - (len + 2))/2 - 1, ACS_RTEE);
- wprintw(win, " %s ", subtitle);
- waddch(win, ACS_LTEE);
-}
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-static void alx_ncur_prn_menu (WINDOW *win,
- int N, struct Alx_Menu mnu[N])
-{
- /* Find size of window */
- int h;
- int w;
- getmaxyx(win, h, w);
-
- /* Print all menu items */
- int i;
- for (i = 0; i < N; i++) {
- mvwaddstr(win, mnu[i].r, mnu[i].c, mnu[i].t);
- }
-
- wrefresh(win);
-}
-
-static int alx_ncur_usr_sel (WINDOW *win,
- int N, struct Alx_Menu mnu[N])
-{
- /* default item */
- int i = 1;
- wmove(win, mnu[i].r, mnu[i].c + 1);
-
- /* Receive input until ENTER key */
- bool wh;
- wchar_t ch;
- wh = true;
- while (wh) {
- /* Input */
- ch = wgetch(win);
-
- switch (ch) {
- case KEY_UP:
- case 'w':
- case 'k':
- /* KEY_UP, move one item up */
- if (i) {
- i--;
- } else {
- i = N - 1;
- }
- wmove(win, mnu[i].r, mnu[i].c + 1);
- break;
-
- case KEY_DOWN:
- case 's':
- case 'j':
- /* KEY_DOWN, move one item down */
- if (i != N - 1) {
- i++;
- } else {
- i = 0;
- }
- wmove(win, mnu[i].r, mnu[i].c + 1);
- break;
-
- /* '\r' is Enter key in Windows */
- case '\r':
- case '\n':
- case ' ':
- /* ENTER / SPACE, end menu */
- wh = false;
- break;
-
- default:
- if ((ch >= '0') && (ch < N + '0')) {
- /* Input is a number, move to that item & end menu */
- i = ch - '0';
- wmove(win, mnu[i].r, mnu[i].c + 1);
- wh = false;
- }
- break;
-
- }
-
- }
-
- return i;
-}
-
-static double loop_w_getdbl (WINDOW *win,
- double m, double def, double M)
-{
- int i;
- char buff [BUFF_SIZE];
- int x;
- double R;
- int err;
-
- for (i = 0; i < MAX_TRIES; i++) {
- echo();
- x = mvwgetnstr(win, 0, 0, buff, BUFF_SIZE);
- noecho();
- wclear(win);
- wrefresh(win);
-
- if (x == ERR) {
- err = ERR_GETSTR;
- } else {
- err = alx_sscan_dbl(&R, m, def, M, buff);
- }
-
- if (err) {
- manage_w_error(win, err);
- } else {
- break;
- }
- }
-
- return R;
-}
-
-static int64_t loop_w_getint (WINDOW *win,
- double m, int64_t def, double M)
-{
- int i;
- char buff [BUFF_SIZE];
- int x;
- int64_t Z;
- int err;
-
- for (i = 0; i < MAX_TRIES; i++) {
- echo();
- x = mvwgetnstr(win, 0, 0, buff, BUFF_SIZE);
- noecho();
- wclear(win);
- wrefresh(win);
-
- if (x == ERR) {
- err = ERR_GETSTR;
- } else {
- err = alx_sscan_int(&Z, m, def, M, buff);
- }
-
- if (err) {
- manage_w_error(win, err);
- } else {
- break;
- }
- }
-
- return Z;
-}
-
-static void loop_w_getstr (char *dest, int destsize, WINDOW *win)
-{
- int i;
- char buff [BUFF_SIZE];
- int x;
- int err;
-
- for (i = 0; i < MAX_TRIES; i++) {
- echo();
- x = mvwgetnstr(win, 0, 0, buff, BUFF_SIZE);
- noecho();
- wclear(win);
- wrefresh(win);
-
- err = ERR_OK;
- if (x == ERR) {
- err = ERR_GETSTR;
- } else {
- break;
- }
-
- if (err) {
- manage_w_error(win, err);
- } else {
- break;
- }
- }
-
- if (!err) {
- snprintf(dest, destsize, "%s", buff);
- }
-}
-
-static void loop_w_getfname (const char *fpath, char *fname, bool exist,
- WINDOW *win)
-{
- int i;
- char buff [FILENAME_MAX];
- int x;
- int err;
-
- for (i = 0; i < MAX_TRIES; i++) {
- echo();
- x = mvwgetnstr(win, 0, 0, buff, FILENAME_MAX);
- noecho();
- wclear(win);
- wrefresh(win);
-
- if (x == ERR) {
- err = ERR_GETSTR;
- } else {
- err = alx_sscan_fname(fpath, fname, exist, buff);
- }
-
- if (err) {
- manage_w_error(win, err);
- } else {
- break;
- }
- }
-}
-
-static void manage_w_error (WINDOW *win, int err)
-{
- switch (err) {
- case ERR_RANGE:
- mvwaddstr(win, 0, 0, ERR_RANGE_MSG);
- break;
- case ERR_SSCANF:
- mvwaddstr(win, 0, 0, ERR_SSCANF_MSG);
- break;
- case ERR_FPTR:
- mvwaddstr(win, 0, 0, ERR_FPTR_MSG);
- break;
- case ERR_GETSTR:
- mvwaddstr(win, 0, 0, ERR_GETSTR_MSG);
- break;
- }
- wrefresh(win);
- /* Wait for any key */
- wgetch(win);
- wclear(win);
- wrefresh(win);
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/src/alx_seed.c b/libalx/src/alx_seed.c deleted file mode 100644 index 7eda90d..0000000 --- a/libalx/src/alx_seed.c +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************
- * Robert Jenkins' 96 bit Mix Function *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * * Standard * * * * * *
- * * * * * * * * * */
- #include <stdint.h>
-
-/* * * * * * * * * *
- * * * Other * * * * * * *
- * * * * * * * * * */
- #include "alx_seed.h"
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-uint32_t seedf (uint32_t a, uint32_t b, uint32_t c)
-{
- a -= b + c;
- a = a ^ (c >> 13);
- b -= c + a;
- b = b ^ (a << 8);
- c -= a + b;
- c = c ^ (b >> 13);
- a -= b + c;
- a = a ^ (c >> 12);
- b -= a + c;
- b = b ^ (a << 16);
- c -= a + b;
- c = c ^ (b >> 5);
- a -= b + c;
- a = a ^ (c >> 3);
- b -= a + c;
- b = b ^ (a << 10);
- c -= a + b;
- c = c ^ (b >> 15);
- return c;
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/libalx/tmp/Makefile b/libalx/tmp/Makefile deleted file mode 100644 index 7595cfd..0000000 --- a/libalx/tmp/Makefile +++ /dev/null @@ -1,106 +0,0 @@ -# -*- MakeFile -*- - -# MACRO = substitute with this - -# directories - -INC_DIR = $(LIBALX_DIR)/inc/ -SRC_DIR = $(LIBALX_DIR)/src/ - -# dependencies - -_ALL = alx_cmp.o alx_file.o alx_input.o alx_mask.o alx_math.o alx_ncur.o alx_seed.o -ALL = $(_ALL) alx_lib.o - -CMP_INC = alx_cmp.h -CMP_DEPS = $(SRC_DIR)/alx_cmp.c $(patsubst %,$(INC_DIR)/%,$(CMP_INC)) -CMP_INC_DIRS = -I $(INC_DIR) - -FILE_INC = alx_file.h -FILE_DEPS = $(SRC_DIR)/alx_file.c $(patsubst %,$(INC_DIR)/%,$(FILE_INC)) -FILE_INC_DIRS = -I $(INC_DIR) - -INPUT_INC = alx_input.h -INPUT_DEPS = $(SRC_DIR)/alx_input.c $(patsubst %,$(INC_DIR)/%,$(INPUT_INC)) -INPUT_INC_DIRS = -I $(INC_DIR) - -MASK_INC = alx_mask.h -MASK_DEPS = $(SRC_DIR)/alx_mask.c $(patsubst %,$(INC_DIR)/%,$(MASK_INC)) -MASK_INC_DIRS = -I $(INC_DIR) - -MATH_INC = alx_math.h -MATH_DEPS = $(SRC_DIR)/alx_math.c $(patsubst %,$(INC_DIR)/%,$(MATH_INC)) -MATH_INC_DIRS = -I $(INC_DIR) - -NCUR_INC = alx_ncur.h alx_input.h -NCUR_DEPS = $(SRC_DIR)/alx_ncur.c $(patsubst %,$(INC_DIR)/%,$(NCUR_INC)) -NCUR_INC_DIRS = -I $(INC_DIR) - -SEED_INC = alx_seed.h -SEED_DEPS = $(SRC_DIR)/alx_seed.c $(patsubst %,$(INC_DIR)/%,$(SEED_INC)) -SEED_INC_DIRS = -I $(INC_DIR) - -# target: dependencies -# action - -all: $(ALL) - - -alx_lib.o: $(_ALL) - $(Q)$(LD) -r $^ -o $@ - @echo " LD $@" - @echo "" - - -alx_cmp.s: $(CMP_DEPS) - $(Q)$(CC) $(CFLAGS) $(CMP_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_cmp.o: alx_cmp.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - -alx_file.s: $(FILE_DEPS) - $(Q)$(CC) $(CFLAGS) $(FILE_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_file.o: alx_file.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - -alx_input.s: $(INPUT_DEPS) - $(Q)$(CC) $(CFLAGS) $(INPUT_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_input.o: alx_input.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - -alx_mask.s: $(MASK_DEPS) - $(Q)$(CC) $(CFLAGS) $(MASK_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_mask.o: alx_mask.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - -alx_math.s: $(MATH_DEPS) - $(Q)$(CC) $(CFLAGS) $(MATH_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_math.o: alx_math.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - -alx_ncur.s: $(NCUR_DEPS) - $(Q)$(CC) $(CFLAGS) $(NCUR_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_ncur.o: alx_ncur.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - -alx_seed.s: $(SEED_DEPS) - $(Q)$(CC) $(CFLAGS) $(SEED_INC_DIRS) -S $< -o $@ - @echo " CC $@" -alx_seed.o: alx_seed.s - $(Q)$(AS) $< -o $@ - @echo " AS $@" - - -clean: - $(Q)rm -f *.o *.s |