aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-10-22 18:59:27 +0200
committerMattias Andrée <maandree@kth.se>2019-10-22 18:59:27 +0200
commitbf4020471356938b9181a33984f511ffdd7ff25b (patch)
tree7f9a9abd1ae51318cd435f0ed7471be5f33b478c
parentList radharc's priority (diff)
downloadlibcoopgamma-bf4020471356938b9181a33984f511ffdd7ff25b.tar.gz
libcoopgamma-bf4020471356938b9181a33984f511ffdd7ff25b.tar.bz2
libcoopgamma-bf4020471356938b9181a33984f511ffdd7ff25b.tar.xz
Change license, change style, clean up, flat file hier, clean valgrind output in test
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--.gitignore21
-rw-r--r--COPYING15
-rw-r--r--DEPENDENCIES1
-rw-r--r--LICENSE683
-rw-r--r--Makefile66
-rw-r--r--Makefile.in74
-rw-r--r--README2
-rw-r--r--config.mk8
-rwxr-xr-xconfigure48
-rw-r--r--libcoopgamma.7 (renamed from doc/man/libcoopgamma.7)0
-rw-r--r--libcoopgamma.c2538
-rw-r--r--libcoopgamma.h (renamed from src/libcoopgamma.h)1237
-rw-r--r--libcoopgamma.h.0 (renamed from doc/man/libcoopgamma.h.0)0
-rw-r--r--libcoopgamma_async_context_destroy.3 (renamed from doc/man/libcoopgamma_async_context_destroy.3)0
-rw-r--r--libcoopgamma_async_context_initialise.3 (renamed from doc/man/libcoopgamma_async_context_initialise.3)0
-rw-r--r--libcoopgamma_async_context_marshal.3 (renamed from doc/man/libcoopgamma_async_context_marshal.3)0
-rw-r--r--libcoopgamma_async_context_unmarshal.3 (renamed from doc/man/libcoopgamma_async_context_unmarshal.3)0
-rw-r--r--libcoopgamma_connect.3 (renamed from doc/man/libcoopgamma_connect.3)0
-rw-r--r--libcoopgamma_context_destroy.3 (renamed from doc/man/libcoopgamma_context_destroy.3)0
-rw-r--r--libcoopgamma_context_initialise.3 (renamed from doc/man/libcoopgamma_context_initialise.3)0
-rw-r--r--libcoopgamma_context_marshal.3 (renamed from doc/man/libcoopgamma_context_marshal.3)0
-rw-r--r--libcoopgamma_context_unmarshal.3 (renamed from doc/man/libcoopgamma_context_unmarshal.3)0
-rw-r--r--libcoopgamma_crtc_info_destroy.3 (renamed from doc/man/libcoopgamma_crtc_info_destroy.3)0
-rw-r--r--libcoopgamma_crtc_info_initialise.3 (renamed from doc/man/libcoopgamma_crtc_info_initialise.3)0
-rw-r--r--libcoopgamma_crtc_info_marshal.3 (renamed from doc/man/libcoopgamma_crtc_info_marshal.3)0
-rw-r--r--libcoopgamma_crtc_info_unmarshal.3 (renamed from doc/man/libcoopgamma_crtc_info_unmarshal.3)0
-rw-r--r--libcoopgamma_error_destroy.3 (renamed from doc/man/libcoopgamma_error_destroy.3)0
-rw-r--r--libcoopgamma_error_initialise.3 (renamed from doc/man/libcoopgamma_error_initialise.3)0
-rw-r--r--libcoopgamma_error_marshal.3 (renamed from doc/man/libcoopgamma_error_marshal.3)0
-rw-r--r--libcoopgamma_error_unmarshal.3 (renamed from doc/man/libcoopgamma_error_unmarshal.3)0
-rw-r--r--libcoopgamma_filter_destroy.3 (renamed from doc/man/libcoopgamma_filter_destroy.3)0
-rw-r--r--libcoopgamma_filter_initialise.3 (renamed from doc/man/libcoopgamma_filter_initialise.3)0
-rw-r--r--libcoopgamma_filter_marshal.3 (renamed from doc/man/libcoopgamma_filter_marshal.3)0
-rw-r--r--libcoopgamma_filter_query_destroy.3 (renamed from doc/man/libcoopgamma_filter_query_destroy.3)0
-rw-r--r--libcoopgamma_filter_query_initialise.3 (renamed from doc/man/libcoopgamma_filter_query_initialise.3)0
-rw-r--r--libcoopgamma_filter_query_marshal.3 (renamed from doc/man/libcoopgamma_filter_query_marshal.3)0
-rw-r--r--libcoopgamma_filter_query_unmarshal.3 (renamed from doc/man/libcoopgamma_filter_query_unmarshal.3)0
-rw-r--r--libcoopgamma_filter_table_destroy.3 (renamed from doc/man/libcoopgamma_filter_table_destroy.3)0
-rw-r--r--libcoopgamma_filter_table_initialise.3 (renamed from doc/man/libcoopgamma_filter_table_initialise.3)0
-rw-r--r--libcoopgamma_filter_table_marshal.3 (renamed from doc/man/libcoopgamma_filter_table_marshal.3)0
-rw-r--r--libcoopgamma_filter_table_unmarshal.3 (renamed from doc/man/libcoopgamma_filter_table_unmarshal.3)0
-rw-r--r--libcoopgamma_filter_unmarshal.3 (renamed from doc/man/libcoopgamma_filter_unmarshal.3)0
-rw-r--r--libcoopgamma_flush.3 (renamed from doc/man/libcoopgamma_flush.3)0
-rw-r--r--libcoopgamma_get_crtcs_recv.3 (renamed from doc/man/libcoopgamma_get_crtcs_recv.3)0
-rw-r--r--libcoopgamma_get_crtcs_send.3 (renamed from doc/man/libcoopgamma_get_crtcs_send.3)0
-rw-r--r--libcoopgamma_get_crtcs_sync.3 (renamed from doc/man/libcoopgamma_get_crtcs_sync.3)0
-rw-r--r--libcoopgamma_get_gamma_info_recv.3 (renamed from doc/man/libcoopgamma_get_gamma_info_recv.3)0
-rw-r--r--libcoopgamma_get_gamma_info_send.3 (renamed from doc/man/libcoopgamma_get_gamma_info_send.3)0
-rw-r--r--libcoopgamma_get_gamma_info_sync.3 (renamed from doc/man/libcoopgamma_get_gamma_info_sync.3)0
-rw-r--r--libcoopgamma_get_gamma_recv.3 (renamed from doc/man/libcoopgamma_get_gamma_recv.3)0
-rw-r--r--libcoopgamma_get_gamma_send.3 (renamed from doc/man/libcoopgamma_get_gamma_send.3)0
-rw-r--r--libcoopgamma_get_gamma_sync.3 (renamed from doc/man/libcoopgamma_get_gamma_sync.3)0
-rw-r--r--libcoopgamma_get_method_and_site.3 (renamed from doc/man/libcoopgamma_get_method_and_site.3)0
-rw-r--r--libcoopgamma_get_methods.3 (renamed from doc/man/libcoopgamma_get_methods.3)0
-rw-r--r--libcoopgamma_get_pid_file.3 (renamed from doc/man/libcoopgamma_get_pid_file.3)0
-rw-r--r--libcoopgamma_get_socket_file.3 (renamed from doc/man/libcoopgamma_get_socket_file.3)0
-rw-r--r--libcoopgamma_queried_filter_destroy.3 (renamed from doc/man/libcoopgamma_queried_filter_destroy.3)0
-rw-r--r--libcoopgamma_queried_filter_initialise.3 (renamed from doc/man/libcoopgamma_queried_filter_initialise.3)0
-rw-r--r--libcoopgamma_queried_filter_marshal.3 (renamed from doc/man/libcoopgamma_queried_filter_marshal.3)0
-rw-r--r--libcoopgamma_queried_filter_unmarshal.3 (renamed from doc/man/libcoopgamma_queried_filter_unmarshal.3)0
-rw-r--r--libcoopgamma_ramps_destroy.3 (renamed from doc/man/libcoopgamma_ramps_destroy.3)0
-rw-r--r--libcoopgamma_ramps_initialise.3 (renamed from doc/man/libcoopgamma_ramps_initialise.3)0
-rw-r--r--libcoopgamma_ramps_marshal.3 (renamed from doc/man/libcoopgamma_ramps_marshal.3)0
-rw-r--r--libcoopgamma_ramps_unmarshal.3 (renamed from doc/man/libcoopgamma_ramps_unmarshal.3)0
-rw-r--r--libcoopgamma_set_gamma_recv.3 (renamed from doc/man/libcoopgamma_set_gamma_recv.3)0
-rw-r--r--libcoopgamma_set_gamma_send.3 (renamed from doc/man/libcoopgamma_set_gamma_send.3)0
-rw-r--r--libcoopgamma_set_gamma_sync.3 (renamed from doc/man/libcoopgamma_set_gamma_sync.3)0
-rw-r--r--libcoopgamma_set_nonblocking.3 (renamed from doc/man/libcoopgamma_set_nonblocking.3)0
-rw-r--r--libcoopgamma_skip_message.3 (renamed from doc/man/libcoopgamma_skip_message.3)0
-rw-r--r--libcoopgamma_synchronise.3 (renamed from doc/man/libcoopgamma_synchronise.3)0
-rw-r--r--linux.mk5
-rw-r--r--macos.mk5
-rw-r--r--man.mk64
-rw-r--r--mk/README71
-rw-r--r--mk/all.mk32
-rw-r--r--mk/clean.mk45
-rw-r--r--mk/configure732
-rw-r--r--mk/copy.mk78
-rw-r--r--mk/dist.mk189
-rw-r--r--mk/empty.mk103
-rw-r--r--mk/i18n.mk111
-rw-r--r--mk/lang-c.mk307
-rw-r--r--mk/lowerpath.mk279
-rw-r--r--mk/man.mk111
-rw-r--r--mk/path.mk176
-rw-r--r--mk/prologue.mk16
-rw-r--r--mk/shell.mk233
-rw-r--r--mk/tags.mk25
-rw-r--r--mk/texinfo.mk294
-rw-r--r--mk/tools.mk163
-rw-r--r--src/libcoopgamma.c2620
-rw-r--r--src/test.c273
-rw-r--r--test.c257
93 files changed, 3558 insertions, 7324 deletions
diff --git a/.gitignore b/.gitignore
index 87ad7ae..6a59d3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,10 @@
-bin/
-obj/
-aux/
-\#*\#
-.\#*
+*\#*
*~
-*.bak
-*.orig
*.o
+*.a
+*.lo
*.su
*.so
-*.out
-*.pdf
-*.dvi
-*.ps
-*.info
-.config.mk
-/config.status
-/Makefile
+*.so.*
+*.dylib
+/test
diff --git a/COPYING b/COPYING
deleted file mode 100644
index db4393a..0000000
--- a/COPYING
+++ /dev/null
@@ -1,15 +0,0 @@
-libcoopgamma -- Library for interfacing with cooperative gamma servers
-Copyright (C) 2016 Mattias Andrée (maandree@kth.se)
-
-This library 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 3 of the License, or
-(at your option) any later version.
-
-This library 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 library. If not, see <http://www.gnu.org/licenses/>.
diff --git a/DEPENDENCIES b/DEPENDENCIES
index 23d8713..420c60b 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -16,4 +16,3 @@ INSTALL DEPENDENCIES:
make
coreutils
-
diff --git a/LICENSE b/LICENSE
index 94a9ed0..c2c5e80 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,15 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
+ISC License
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
+© 2016, 2019 Mattias Andrée <maandree@kth.se>
- Preamble
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. 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
-them 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 prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. 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.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey 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;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If 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 convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- 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.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-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.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- 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
-state 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 3 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, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program 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, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU 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 Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ab595c6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,66 @@
+.POSIX:
+
+LIB_MAJOR = 1
+LIB_MINOR = 2
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+
+CONFIGFILE = config.mk
+OSCONFIGFILE = linux.mk
+
+include $(CONFIGFILE)
+include $(OSCONFIGFILE)
+include man.mk
+
+all: libcoopgamma.a libcoopgamma.so test
+
+.c.o:
+ $(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
+
+.c.lo:
+ $(CC) -fPIC -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
+
+libcoopgamma.a: libcoopgamma.o
+ $(AR) rc $@ $?
+ $(AR) s $@
+
+libcoopgamma.$(LIBEXT): libcoopgamma.lo
+ $(CC) $(LIBFLAGS) -o $@ libcoopgamma.lo $(LDFLAGS)
+
+test: test.o libcoopgamma.a
+ $(CC) -o $@ test.o libcoopgamma.a $(LDFLAGS)
+
+check: test
+ ./test
+
+install: libcoopgamma.a libcoopgamma.$(LIBEXT)
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man0"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
+ cp -- libcoopgamma.h "$(DESTDIR)$(PREFIX)/include"
+ cp -- libcoopgamma.a "$(DESTDIR)$(PREFIX)/lib"
+ cp -- libcoopgamma.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.$(LIBMINOREXT)"
+ ln -sf -- libcoopgamma.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.$(LIBMAJOREXT)"
+ ln -sf -- libcoopgamma.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.$(LIBEXT)"
+ cp -- $(MAN0) "$(DESTDIR)$(MANPREFIX)/man0"
+ cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3"
+ cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7"
+
+uninstall:
+ -rm -f -- "$(DESTDIR)$(PREFIX)/include/libcoopgamma.h"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.a"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.$(LIBMINOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.$(LIBMAJOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcoopgamma.$(LIBEXT)"
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man0/" && rm -f -- $(MAN0)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man3/" && rm -f -- $(MAN3)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man7/" && rm -f -- $(MAN7)
+
+clean:
+ -rm -f -- *.a *.lo *.o *.su *.$(LIBEXT) test
+
+.SUFFIXES:
+.SUFFIXES: .lo .o .c
+
+.PHONY: all check install uninstall clean
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index b3a1e2e..0000000
--- a/Makefile.in
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright (C) 2016 Mattias Andrée <maandree@kth.se>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-### This file will be stored to Makefile once you have run ./configure. ###
-### See INSTALL for information on how to install this package. ###
-
-
-
-##### What is below this line is configurable, but is seldom useful. #####
-
-
-# The name of the package as it should be installed.
-PKGNAME = libcoopgamma
-
-
-
-##### Nothing interesting below this. #####
-
-
-# In case you want add some configurations. Primarily
-# intended for maintainers. Perhaps add GPG_KEY here.
-# Of course, you can declare everthing with ./configure,
-# but with this you are less likely to forget it.
--include .make-configurations
-
-
-# YOU, AS A USER, SHOULD NOT CHANGE THESE VARIABLES. {{
-# They specify how the reusable makefiles in mk/ shall behave.
-
-# Package information.
-_PROJECT = libcoopgamma
-_VERSION = 1.2
-
-# Used by mk/lang-c.mk
-_C_STD = c99
-_PEDANTIC = yes
-_LIB = libcoopgamma
-_OBJ_libcoopgamma = libcoopgamma
-_SO_VERSION_libcoopgamma = $(_VERSION)
-_SO_MAJOR_libcoopgamma = $(shell echo $(_SO_VERSION_libcoopgamma) | cut -d . -f 1)
-_H = libcoopgamma
-_HEADER_DIRLEVELS = 1
-_CPPFLAGS = -D'PACKAGE="$(PKGNAME)"' -D'PROGRAM_VERSION="$(_VERSION)"'
-
-# Used by mk/man.mk
-_MAN_PAGE_SECTIONS = 0 3 7
-_MAN_0 = libcoopgamma.h
-__TYPES = async_context context crtc_info error filter filter_query filter_table queried_filter ramps
-__PROTOCOLS = get_crtcs get_gamma_info get_gamma set_gamma
-_MAN_3 = $(foreach T,$(__TYPES),$(foreach F,destroy initialise marshal unmarshal,libcoopgamma_$(T)_$(F))) \
- $(foreach P,$(__PROTOCOLS),$(foreach F,recv send sync,libcoopgamma_$(P)_$(F))) \
- libcoopgamma_connect libcoopgamma_flush libcoopgamma_get_method_and_site \
- libcoopgamma_get_methods libcoopgamma_get_pid_file libcoopgamma_get_socket_file \
- libcoopgamma_set_nonblocking libcoopgamma_synchronise libcoopgamma_skip_message
-_MAN_7 = libcoopgamma
-
-# Used by mk/copy.mk
-_COPYING = COPYING LICENSE
-
-# Used by mk/dist.mk
-_EVERYTHING = $(__EVERYTHING_ALL_COMMON) src/libcoopgamma.c src/libcoopgamma.h \
- DEPENDENCIES
-
-# }}
-
-
-# All of the make rules and the configurations.
-include $(v)mk/all.mk
-
diff --git a/README b/README
index 53dd625..b0d6c4a 100644
--- a/README
+++ b/README
@@ -28,4 +28,4 @@ RATIONALE
SEE ALSO
libcoopgamma.h(0), coopgammad(1), gc-tools(7),
- libclut(7)
+ libclut(7).
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..ca1ffbb
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,8 @@
+PREFIX = /usr
+MANPREFIX = $(PREFIX)/share/man
+
+CC = cc
+
+CPPFLAGS = -D_DEFAULT_SOURCE -D_GNU_SOURCE
+CFLAGS = -std=c99 -Wall -Og -g
+LDFLAGS =
diff --git a/configure b/configure
deleted file mode 100755
index 4d0e5d5..0000000
--- a/configure
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2016 Mattias Andrée <maandree@kth.se>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# Run './configure --help' for usage information.
-
-
-PKGNAME=libcoopgamma
-MAN_SECTION_SUFFIX=
-
-
-list_optional_features_help ()
-{
- true
-}
-
-unrecognised_argument ()
-{
- option="${1}"
- case "${option}" in
- (--build | --target | --host)
- incomplete="${option}" ;;
- (--build=*)
- ;;
- (--target=*)
- ;;
- (--host=*)
- ;;
- (*)
- ;;
- esac
-}
-
-. "$(dirname "${0}")"/mk/configure
-
-
-cat <<EOF
-
-You can now run 'make && make install'.
-
-EOF
-
diff --git a/doc/man/libcoopgamma.7 b/libcoopgamma.7
index 2e11d27..2e11d27 100644
--- a/doc/man/libcoopgamma.7
+++ b/libcoopgamma.7
diff --git a/libcoopgamma.c b/libcoopgamma.c
new file mode 100644
index 0000000..30a68fe
--- /dev/null
+++ b/libcoopgamma.c
@@ -0,0 +1,2538 @@
+/* See LICENSE file for copyright and license details. */
+#include "libcoopgamma.h"
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <poll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+#if !defined(COOPGAMMAD)
+# define COOPGAMMAD "coopgammad"
+#endif
+
+
+#if defined(__clang__)
+# pragma GCC diagnostic ignored "-Wdocumentation"
+# pragma GCC diagnostic ignored "-Wcovered-switch-default"
+# pragma GCC diagnostic ignored "-Wcast-align"
+#endif
+
+
+#if defined(__GNUC__)
+# define NAME_OF_THE_PROCESS (argv0)
+extern const char *argv0;
+const char *argv0 __attribute__((weak)) = "libcoopgamma";
+#else
+# define NAME_OF_THE_PROCESS ("libcoopgamma")
+#endif
+
+
+
+#define SUBBUF\
+ (buf ? &buf[off] : NULL)
+
+#define NNSUBBUF\
+ (buf + off)
+
+#define MARSHAL_PROLOGUE\
+ char *restrict buf = vbuf;\
+ size_t off = 0;
+
+#define UNMARSHAL_PROLOGUE\
+ const char *restrict buf = vbuf;\
+ size_t off = 0;
+
+#define MARSHAL_EPILOGUE\
+ return off
+
+#define UNMARSHAL_EPILOGUE\
+ return *np = off, LIBCOOPGAMMA_SUCCESS
+
+#define marshal_prim(datum, type)\
+ ((buf != NULL ? *(type *)&buf[off] = (datum) : 0), off += sizeof(type))
+
+#define unmarshal_prim(datum, type)\
+ ((datum) = *(const type *)&buf[off], off += sizeof(type))
+
+#define marshal_version(version)\
+ marshal_prim(version, int)
+
+#define unmarshal_version(version)\
+ do {\
+ int version__;\
+ unmarshal_prim(version__, int);\
+ if (version__ < (version))\
+ return LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE;\
+ if (version__ > (version))\
+ return LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE;\
+ } while (0)
+
+#define marshal_buffer(data, n)\
+ ((buf ? (memcpy(buf + off, (data), (n)), 0) : 0), off += (n))
+
+#define unmarshal_buffer(data, n)\
+ do {\
+ (data) = malloc(n);\
+ if (!(data))\
+ return LIBCOOPGAMMA_ERRNO_SET;\
+ memcpy((data), &buf[off], (n));\
+ off += (n);\
+ } while (0)
+
+#define marshal_string(datum)\
+ (!(datum) ? marshal_prim(0, char) :\
+ (marshal_prim(1, char), marshal_buffer((datum), strlen(datum) + 1)))
+
+#define unmarshal_string(datum)\
+ do {\
+ char nonnull__;\
+ unmarshal_prim(nonnull__, char);\
+ if (nonnull__)\
+ unmarshal_buffer((datum), strlen(buf + off) + 1);\
+ else\
+ (datum) = NULL;\
+ } while (0)
+
+
+
+#define copy_errno(ctx)\
+ (!errno ? NULL :\
+ ((ctx)->error.number = (uint64_t)errno,\
+ (ctx)->error.custom = 0,\
+ (ctx)->error.server_side = 0,\
+ free((ctx)->error.description),\
+ (ctx)->error.description = NULL))
+
+
+#define SYNC_CALL(send_call, recv_call, fail_return)\
+ libcoopgamma_async_context_t async;\
+ if (send_call < 0) {\
+ reflush:\
+ if (errno != EINTR)\
+ return fail_return;\
+ if (libcoopgamma_flush(ctx) < 0)\
+ goto reflush;\
+ }\
+ resync:\
+ if (libcoopgamma_synchronise(ctx, &async, (size_t)1, &(size_t){0}) < 0) {\
+ if (errno != EINTR && errno)\
+ return fail_return;\
+ goto resync;\
+ }\
+ return recv_call
+
+
+#define INTEGRAL_DEPTHS\
+ case LIBCOOPGAMMA_UINT8:\
+ case LIBCOOPGAMMA_UINT16:\
+ case LIBCOOPGAMMA_UINT32:\
+ case LIBCOOPGAMMA_UINT64:
+
+
+
+/**
+ * Initialise a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
+ * `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`, or `libcoopgamma_rampsd_t`
+ *
+ * `this->red_size`, `this->green_size`, and `this->blue_size` must already be set
+ *
+ * @param this The record to initialise
+ * @param width The `sizeof(*(this->red))`
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_ramps_initialise_(void *restrict this, size_t width)
+{
+ libcoopgamma_ramps8_t *restrict this8 = (libcoopgamma_ramps8_t *restrict)this;
+ this8->red = this8->green = this8->blue = NULL;
+ this8->red = malloc((this8->red_size + this8->green_size + this8->blue_size) * width);
+ if (!this8->red)
+ return -1;
+ this8->green = this8->red + this8->red_size * width;
+ this8->blue = this8->green + this8->green_size * width;
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`,
+ * `libcoopgamma_ramps32_t`, `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`,
+ * `libcoopgamma_rampsd_t`, or `libcoopgamma_ramps_t`, the allocation of the record
+ * itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_ramps_initialise`
+ * or failed call to `libcoopgamma_ramps_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_ramps_destroy(void *restrict this)
+{
+ libcoopgamma_ramps8_t *restrict this8 = (libcoopgamma_ramps8_t *restrict)this;
+ free(this8->red);
+ this8->red = this8->green = this8->blue = NULL;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
+ * `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`, or `libcoopgamma_rampsd_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @param width The `sizeof(*(this->red))`
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_ramps_marshal_(const void *restrict this, void *restrict vbuf, size_t width)
+{
+ const libcoopgamma_ramps8_t *restrict this8 = (const libcoopgamma_ramps8_t *restrict)this;
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_RAMPS_VERSION);
+ marshal_prim(this8->red_size, size_t);
+ marshal_prim(this8->green_size, size_t);
+ marshal_prim(this8->blue_size, size_t);
+ marshal_buffer(this8->red, (this8->red_size + this8->green_size + this8->blue_size) * width);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
+ * `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`, or `libcoopgamma_rampsd_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @param width The `sizeof(*(this->red))`
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_ramps_unmarshal_(void *restrict this, const void *restrict vbuf,
+ size_t *restrict np, size_t width)
+{
+ libcoopgamma_ramps8_t *restrict this8 = (libcoopgamma_ramps8_t *restrict)this;
+ UNMARSHAL_PROLOGUE;
+ unmarshal_version(LIBCOOPGAMMA_RAMPS_VERSION);
+ unmarshal_prim(this8->red_size, size_t);
+ unmarshal_prim(this8->green_size, size_t);
+ unmarshal_prim(this8->blue_size, size_t);
+ unmarshal_buffer(this8->red, (this8->red_size + this8->green_size + this8->blue_size) * width);
+ this8->green = this8->red + this8->red_size * width;
+ this8->blue = this8->green + this8->green_size * width;
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_filter_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_filter_initialise(libcoopgamma_filter_t *restrict this)
+{
+ memset(this, 0, sizeof(*this));
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_filter_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_filter_initialise`
+ * or failed call to `libcoopgamma_filter_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_filter_destroy(libcoopgamma_filter_t *restrict this)
+{
+ free(this->crtc);
+ free(this->class);
+ free(this->ramps.u8.red);
+ memset(this, 0, sizeof(*this));
+}
+
+
+/**
+ * Marshal a `libcoopgamma_filter_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_filter_marshal(const libcoopgamma_filter_t *restrict this, void *restrict vbuf)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_FILTER_VERSION);
+ marshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
+ marshal_version(LIBCOOPGAMMA_LIFESPAN_VERSION);
+ marshal_prim(this->depth, libcoopgamma_depth_t);
+ marshal_prim(this->priority, int64_t);
+ marshal_string(this->crtc);
+ marshal_string(this->class);
+ marshal_prim(this->lifespan, libcoopgamma_lifespan_t);
+ switch (this->depth) {
+ case LIBCOOPGAMMA_UINT8: off += libcoopgamma_ramps_marshal(&this->ramps.u8, SUBBUF); break;
+ case LIBCOOPGAMMA_UINT16: off += libcoopgamma_ramps_marshal(&this->ramps.u16, SUBBUF); break;
+ case LIBCOOPGAMMA_UINT32: off += libcoopgamma_ramps_marshal(&this->ramps.u32, SUBBUF); break;
+ case LIBCOOPGAMMA_UINT64: off += libcoopgamma_ramps_marshal(&this->ramps.u64, SUBBUF); break;
+ case LIBCOOPGAMMA_FLOAT: off += libcoopgamma_ramps_marshal(&this->ramps.f, SUBBUF); break;
+ case LIBCOOPGAMMA_DOUBLE: off += libcoopgamma_ramps_marshal(&this->ramps.d, SUBBUF); break;
+ default:
+ break;
+ }
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_filter_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_filter_unmarshal(libcoopgamma_filter_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ int r = LIBCOOPGAMMA_SUCCESS;
+ size_t n = 0;
+ UNMARSHAL_PROLOGUE;
+ memset(this, 0, sizeof(*this));
+ unmarshal_version(LIBCOOPGAMMA_FILTER_VERSION);
+ unmarshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
+ unmarshal_version(LIBCOOPGAMMA_LIFESPAN_VERSION);
+ unmarshal_prim(this->depth, libcoopgamma_depth_t);
+ unmarshal_prim(this->priority, int64_t);
+ unmarshal_string(this->crtc);
+ unmarshal_string(this->class);
+ unmarshal_prim(this->lifespan, libcoopgamma_lifespan_t);
+ switch (this->depth) {
+ case LIBCOOPGAMMA_UINT8: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u8), NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_UINT16: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u16), NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_UINT32: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u32), NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_UINT64: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u64), NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_FLOAT: r = libcoopgamma_ramps_unmarshal(&(this->ramps.f), NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_DOUBLE: r = libcoopgamma_ramps_unmarshal(&(this->ramps.d), NNSUBBUF, &n); break;
+ default:
+ break;
+ }
+ if (r != LIBCOOPGAMMA_SUCCESS)
+ return r;
+ off += n;
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_crtc_info_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_crtc_info_initialise(libcoopgamma_crtc_info_t *restrict this)
+{
+ memset(this, 0, sizeof(*this));
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_crtc_info_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_crtc_info_initialise`
+ * or failed call to `libcoopgamma_crtc_info_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_crtc_info_destroy(libcoopgamma_crtc_info_t *restrict this)
+{
+ (void) this;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_crtc_info_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_crtc_info_marshal(const libcoopgamma_crtc_info_t *restrict this, void *restrict vbuf)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_CRTC_INFO_VERSION);
+ marshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
+ marshal_version(LIBCOOPGAMMA_SUPPORT_VERSION);
+ marshal_version(LIBCOOPGAMMA_COLOURSPACE_VERSION);
+ marshal_prim(this->cooperative, int);
+ marshal_prim(this->depth, libcoopgamma_depth_t);
+ marshal_prim(this->red_size, size_t);
+ marshal_prim(this->green_size, size_t);
+ marshal_prim(this->blue_size, size_t);
+ marshal_prim(this->supported, libcoopgamma_support_t);
+ marshal_prim(this->colourspace, libcoopgamma_colourspace_t);
+ marshal_prim(this->have_gamut, int);
+ marshal_prim(this->red_x, unsigned);
+ marshal_prim(this->red_y, unsigned);
+ marshal_prim(this->green_x, unsigned);
+ marshal_prim(this->green_y, unsigned);
+ marshal_prim(this->blue_x, unsigned);
+ marshal_prim(this->blue_y, unsigned);
+ marshal_prim(this->white_x, unsigned);
+ marshal_prim(this->white_y, unsigned);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_crtc_info_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_crtc_info_unmarshal(libcoopgamma_crtc_info_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ UNMARSHAL_PROLOGUE;
+ unmarshal_version(LIBCOOPGAMMA_CRTC_INFO_VERSION);
+ unmarshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
+ unmarshal_version(LIBCOOPGAMMA_SUPPORT_VERSION);
+ unmarshal_version(LIBCOOPGAMMA_COLOURSPACE_VERSION);
+ unmarshal_prim(this->cooperative, int);
+ unmarshal_prim(this->depth, libcoopgamma_depth_t);
+ unmarshal_prim(this->red_size, size_t);
+ unmarshal_prim(this->green_size, size_t);
+ unmarshal_prim(this->blue_size, size_t);
+ unmarshal_prim(this->supported, libcoopgamma_support_t);
+ unmarshal_prim(this->colourspace, libcoopgamma_colourspace_t);
+ unmarshal_prim(this->have_gamut, int);
+ unmarshal_prim(this->red_x, unsigned);
+ unmarshal_prim(this->red_y, unsigned);
+ unmarshal_prim(this->green_x, unsigned);
+ unmarshal_prim(this->green_y, unsigned);
+ unmarshal_prim(this->blue_x, unsigned);
+ unmarshal_prim(this->blue_y, unsigned);
+ unmarshal_prim(this->white_x, unsigned);
+ unmarshal_prim(this->white_y, unsigned);
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_filter_query_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_filter_query_initialise(libcoopgamma_filter_query_t *restrict this)
+{
+ this->crtc = NULL;
+ this->coalesce = 0;
+ this->high_priority = INT64_MAX;
+ this->low_priority = INT64_MIN;
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_filter_query_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_filter_query_initialise`
+ * or failed call to `libcoopgamma_filter_query_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_filter_query_destroy(libcoopgamma_filter_query_t *restrict this)
+{
+ free(this->crtc);
+ this->crtc = NULL;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_filter_query_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_filter_query_marshal(const libcoopgamma_filter_query_t *restrict this, void* restrict vbuf)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_FILTER_QUERY_VERSION);
+ marshal_string(this->crtc);
+ marshal_prim(this->coalesce, int);
+ marshal_prim(this->high_priority, int64_t);
+ marshal_prim(this->low_priority, int64_t);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_filter_query_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_filter_query_unmarshal(libcoopgamma_filter_query_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ UNMARSHAL_PROLOGUE;
+ this->crtc = NULL;
+ unmarshal_version(LIBCOOPGAMMA_FILTER_QUERY_VERSION);
+ unmarshal_string(this->crtc);
+ unmarshal_prim(this->coalesce, int);
+ unmarshal_prim(this->high_priority, int64_t);
+ unmarshal_prim(this->low_priority, int64_t);
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_queried_filter_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_queried_filter_initialise(libcoopgamma_queried_filter_t *restrict this)
+{
+ memset(this, 0, sizeof(*this));
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_queried_filter_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_queried_filter_initialise`
+ * or failed call to `libcoopgamma_queried_filter_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_queried_filter_destroy(libcoopgamma_queried_filter_t *restrict this)
+{
+ free(this->class);
+ this->class = NULL;
+ libcoopgamma_ramps_destroy(&this->ramps.u8);
+}
+
+
+/**
+ * Marshal a `libcoopgamma_queried_filter_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @param depth The type used of ramp stops
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_queried_filter_marshal(const libcoopgamma_queried_filter_t *restrict this,
+ void *restrict vbuf, libcoopgamma_depth_t depth)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_QUERIED_FILTER_VERSION);
+ marshal_prim(this->priority, int64_t);
+ marshal_string(this->class);
+ switch (depth) {
+ case LIBCOOPGAMMA_UINT8: off += libcoopgamma_ramps_marshal(&this->ramps.u8, SUBBUF); break;
+ case LIBCOOPGAMMA_UINT16: off += libcoopgamma_ramps_marshal(&this->ramps.u16, SUBBUF); break;
+ case LIBCOOPGAMMA_UINT32: off += libcoopgamma_ramps_marshal(&this->ramps.u32, SUBBUF); break;
+ case LIBCOOPGAMMA_UINT64: off += libcoopgamma_ramps_marshal(&this->ramps.u64, SUBBUF); break;
+ case LIBCOOPGAMMA_FLOAT: off += libcoopgamma_ramps_marshal(&this->ramps.f, SUBBUF); break;
+ case LIBCOOPGAMMA_DOUBLE: off += libcoopgamma_ramps_marshal(&this->ramps.d, SUBBUF); break;
+ default:
+ break;
+ }
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_queried_filter_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @param depth The type used of ramp stops
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int libcoopgamma_queried_filter_unmarshal(libcoopgamma_queried_filter_t *restrict this, const void *restrict vbuf,
+ size_t *restrict np, libcoopgamma_depth_t depth)
+{
+ int r = LIBCOOPGAMMA_SUCCESS;
+ size_t n = 0;
+ UNMARSHAL_PROLOGUE;
+ memset(this, 0, sizeof(*this));
+ unmarshal_version(LIBCOOPGAMMA_QUERIED_FILTER_VERSION);
+ unmarshal_prim(this->priority, int64_t);
+ unmarshal_string(this->class);
+ switch (depth) {
+ case LIBCOOPGAMMA_UINT8: r = libcoopgamma_ramps_unmarshal(&this->ramps.u8, NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_UINT16: r = libcoopgamma_ramps_unmarshal(&this->ramps.u16, NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_UINT32: r = libcoopgamma_ramps_unmarshal(&this->ramps.u32, NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_UINT64: r = libcoopgamma_ramps_unmarshal(&this->ramps.u64, NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_FLOAT: r = libcoopgamma_ramps_unmarshal(&this->ramps.f, NNSUBBUF, &n); break;
+ case LIBCOOPGAMMA_DOUBLE: r = libcoopgamma_ramps_unmarshal(&this->ramps.d, NNSUBBUF, &n); break;
+ default:
+ break;
+ }
+ if (r != LIBCOOPGAMMA_SUCCESS)
+ return r;
+ off += n;
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_filter_table_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_filter_table_initialise(libcoopgamma_filter_table_t *restrict this)
+{
+ memset(this, 0, sizeof(*this));
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_filter_table_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_filter_table_initialise`
+ * or failed call to `libcoopgamma_filter_table_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_filter_table_destroy(libcoopgamma_filter_table_t *restrict this)
+{
+ while (this->filter_count)
+ libcoopgamma_queried_filter_destroy(this->filters + --this->filter_count);
+ free(this->filters);
+ this->filters = NULL;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_filter_table_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_filter_table_marshal(const libcoopgamma_filter_table_t *restrict this, void *restrict vbuf)
+{
+ size_t i;
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_FILTER_TABLE_VERSION);
+ marshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
+ marshal_prim(this->depth, libcoopgamma_depth_t);
+ marshal_prim(this->red_size, size_t);
+ marshal_prim(this->green_size, size_t);
+ marshal_prim(this->blue_size, size_t);
+ marshal_prim(this->filter_count, size_t);
+ for (i = 0; i < this->filter_count; i++)
+ off += libcoopgamma_queried_filter_marshal(&this->filters[i], SUBBUF, this->depth);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_filter_table_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_filter_table_unmarshal(libcoopgamma_filter_table_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ size_t i, n, fn;
+ int r;
+ UNMARSHAL_PROLOGUE;
+ this->filter_count = 0;
+ this->filters = NULL;
+ unmarshal_version(LIBCOOPGAMMA_FILTER_TABLE_VERSION);
+ unmarshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
+ unmarshal_prim(this->depth, libcoopgamma_depth_t);
+ unmarshal_prim(this->red_size, size_t);
+ unmarshal_prim(this->green_size, size_t);
+ unmarshal_prim(this->blue_size, size_t);
+ unmarshal_prim(fn, size_t);
+ this->filters = malloc(fn * sizeof(*this->filters));
+ if (!this->filters)
+ return LIBCOOPGAMMA_ERRNO_SET;
+ for (i = 0; i < fn; i++) {
+ r = libcoopgamma_queried_filter_unmarshal(&this->filters[i], NNSUBBUF, &n, this->depth);
+ if (r != LIBCOOPGAMMA_SUCCESS)
+ return r;
+ off += n;
+ this->filter_count += 1;
+ }
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_error_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_error_initialise(libcoopgamma_error_t *restrict this)
+{
+ this->number = 0;
+ this->custom = 0;
+ this->description = NULL;
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_error_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_error_initialise`
+ * or failed call to `libcoopgamma_error_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_error_destroy(libcoopgamma_error_t *restrict this)
+{
+ free(this->description);
+ this->description = NULL;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_error_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_error_marshal(const libcoopgamma_error_t *restrict this, void *restrict vbuf)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_ERROR_VERSION);
+ marshal_prim(this->number, uint64_t);
+ marshal_prim(this->custom, int);
+ marshal_prim(this->server_side, int);
+ marshal_string(this->description);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_error_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_error_unmarshal(libcoopgamma_error_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ UNMARSHAL_PROLOGUE;
+ this->description = NULL;
+ unmarshal_version(LIBCOOPGAMMA_ERROR_VERSION);
+ unmarshal_prim(this->number, uint64_t);
+ unmarshal_prim(this->custom, int);
+ unmarshal_prim(this->server_side, int);
+ unmarshal_string(this->description);
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_context_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_context_initialise(libcoopgamma_context_t *restrict this)
+{
+ memset(this, 0, sizeof(*this));
+ this->fd = -1;
+ this->blocking = 1;
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_context_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_context_initialise`
+ * or failed call to `libcoopgamma_context_unmarshal`
+ *
+ * @param this The record to destroy
+ * @param disconnect Disconnect from the server?
+ */
+void
+libcoopgamma_context_destroy(libcoopgamma_context_t *restrict this, int disconnect)
+{
+ if (disconnect && this->fd >= 0) {
+ shutdown(this->fd, SHUT_RDWR);
+ close(this->fd);
+ }
+ this->fd = -1;
+ libcoopgamma_error_destroy(&this->error);
+ free(this->outbound);
+ free(this->inbound);
+ this->outbound = NULL;
+ this->inbound = NULL;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_context_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_context_marshal(const libcoopgamma_context_t *restrict this, void *restrict vbuf)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_CONTEXT_VERSION);
+ marshal_prim(this->fd, int);
+ off += libcoopgamma_error_marshal(&this->error, SUBBUF);
+ marshal_prim(this->message_id, uint32_t);
+ marshal_prim(this->outbound_head - this->outbound_tail, size_t);
+ marshal_buffer(this->outbound + this->outbound_tail, this->outbound_head - this->outbound_tail);
+ marshal_prim(this->inbound_head - this->inbound_tail, size_t);
+ marshal_buffer(this->inbound + this->inbound_tail, this->inbound_head - this->inbound_tail);
+ marshal_prim(this->length, size_t);
+ marshal_prim(this->curline, size_t);
+ marshal_prim(this->in_response_to, uint32_t);
+ marshal_prim(this->have_all_headers, int);
+ marshal_prim(this->bad_message, int);
+ marshal_prim(this->blocking, int);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_context_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_context_unmarshal(libcoopgamma_context_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ size_t n;
+ int r;
+ UNMARSHAL_PROLOGUE;
+ memset(this, 0, sizeof(*this));
+ unmarshal_version(LIBCOOPGAMMA_CONTEXT_VERSION);
+ unmarshal_prim(this->fd, int);
+ r = libcoopgamma_error_unmarshal(&this->error, NNSUBBUF, &n);
+ if (r != LIBCOOPGAMMA_SUCCESS)
+ return r;
+ off += n;
+ unmarshal_prim(this->message_id, uint32_t);
+ unmarshal_prim(this->outbound_head, size_t);
+ this->outbound_size = this->outbound_head;
+ unmarshal_buffer(this->outbound, this->outbound_head);
+ unmarshal_prim(this->inbound_head, size_t);
+ this->inbound_size = this->inbound_head;
+ unmarshal_buffer(this->inbound, this->inbound_head);
+ unmarshal_prim(this->length, size_t);
+ unmarshal_prim(this->curline, size_t);
+ unmarshal_prim(this->in_response_to, uint32_t);
+ unmarshal_prim(this->have_all_headers, int);
+ unmarshal_prim(this->bad_message, int);
+ unmarshal_prim(this->blocking, int);
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * Initialise a `libcoopgamma_async_context_t`
+ *
+ * @param this The record to initialise
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_async_context_initialise(libcoopgamma_async_context_t *restrict this)
+{
+ this->message_id = 0;
+ this->coalesce = 0;
+ return 0;
+}
+
+
+/**
+ * Release all resources allocated to a `libcoopgamma_async_context_t`,
+ * the allocation of the record itself is not freed
+ *
+ * Always call this function after failed call to `libcoopgamma_async_context_initialise`
+ * or failed call to `libcoopgamma_async_context_unmarshal`
+ *
+ * @param this The record to destroy
+ */
+void
+libcoopgamma_async_context_destroy(libcoopgamma_async_context_t *restrict this)
+{
+ (void) this;
+}
+
+
+/**
+ * Marshal a `libcoopgamma_async_context_t` into a buffer
+ *
+ * @param this The record to marshal
+ * @param vbuf The output buffer, `NULL` to only measure
+ * how large this buffer has to be
+ * @return The number of marshalled bytes, or if `buf == NULL`,
+ * how many bytes would be marshalled if `buf != NULL`
+ */
+size_t
+libcoopgamma_async_context_marshal(const libcoopgamma_async_context_t *restrict this, void *restrict vbuf)
+{
+ MARSHAL_PROLOGUE;
+ marshal_version(LIBCOOPGAMMA_ASYNC_CONTEXT_VERSION);
+ marshal_prim(this->message_id, uint32_t);
+ marshal_prim(this->coalesce, int);
+ MARSHAL_EPILOGUE;
+}
+
+
+/**
+ * Unmarshal a `libcoopgamma_async_context_t` from a buffer
+ *
+ * @param this The output parameter for unmarshalled record
+ * @param vbuf The buffer with the marshalled record
+ * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
+ * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
+ * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
+ */
+int
+libcoopgamma_async_context_unmarshal(libcoopgamma_async_context_t *restrict this, const void *restrict vbuf, size_t *restrict np)
+{
+ UNMARSHAL_PROLOGUE;
+ unmarshal_version(LIBCOOPGAMMA_ASYNC_CONTEXT_VERSION);
+ unmarshal_prim(this->message_id, uint32_t);
+ unmarshal_prim(this->coalesce, int);
+ UNMARSHAL_EPILOGUE;
+}
+
+
+
+/**
+ * List all recognised adjustment method
+ *
+ * SIGCHLD must not be ignored or blocked
+ *
+ * @return A `NULL`-terminated list of names. You should only free
+ * the outer pointer, inner pointers are subpointers of the
+ * outer pointer and cannot be freed. `NULL` on error.
+ */
+char **
+libcoopgamma_get_methods(void)
+{
+ char num[5]; /* The size is base on the fact that we have limited `n` in the loop below */
+ char **methods = NULL;
+ char *method;
+ char **rc;
+ char *buffer;
+ int n = 0;
+ size_t size = 0;
+ void *new;
+
+ methods = malloc(4 * sizeof(*methods));
+ if (!methods)
+ goto fail;
+
+ for (n = 0; n < 10000 /* just to be safe */; n++) {
+ if (n >= 4 && (n & -n) == n) {
+ new = realloc(methods, (size_t)(n << 1) * sizeof(*methods));
+ if (!new)
+ goto fail;
+ methods = new;
+ }
+ sprintf(num, "%i", n);
+ if (libcoopgamma_get_method_and_site(num, NULL, &method, NULL))
+ goto fail;
+ if (!strcmp(method, num)) {
+ free(method);
+ break;
+ }
+ methods[n] = method;
+ size += strlen(method) + 1;
+ }
+
+ rc = malloc((size_t)(n + 1) * sizeof(char *) + size);
+ if (!rc)
+ goto fail;
+ buffer = ((char *)rc) + (size_t)(n + 1) * sizeof(char *);
+ rc[n] = NULL;
+ while (n--) {
+ rc[n] = buffer;
+ buffer = stpcpy(buffer, methods[n]) + 1;
+ free(methods[n]);
+ }
+ free(methods);
+
+ return rc;
+
+fail:
+ while (n--)
+ free(methods[n]);
+ free(methods);
+ return NULL;
+}
+
+
+/**
+ * Run coopgammad with -q or -qq and return the response
+ *
+ * SIGCHLD must not be ignored or blocked
+ *
+ * @param method The adjustment method, `NULL` for automatic
+ * @param site The site, `NULL` for automatic
+ * @param arg "-q" or "-qq", which shall be passed to coopgammad?
+ * @return The output of coopgammad, `NULL` on error. This
+ * will be NUL-terminated and will not contain any
+ * other `NUL` bytes.
+ */
+static char *
+libcoopgamma_query(const char *restrict method, const char *restrict site, const char *restrict arg)
+{
+ const char *(args[7]) = {COOPGAMMAD, arg};
+ size_t i = 2, n = 0, size = 0;
+ int pipe_rw[2] = { -1, -1 };
+ pid_t pid;
+ int saved_errno, status;
+ char *msg = NULL;
+ ssize_t got;
+ void *new;
+
+ if (method) args[i++] = "-m", args[i++] = method;
+ if (site) args[i++] = "-s", args[i++] = site;
+ args[i] = NULL;
+
+ if (pipe(pipe_rw) < 0)
+ goto fail;
+
+ switch ((pid = fork())) {
+ case -1:
+ goto fail;
+
+ case 0:
+ /* Child */
+ close(pipe_rw[0]);
+ if (pipe_rw[1] != STDOUT_FILENO) {
+ close(STDOUT_FILENO);
+ if (dup2(pipe_rw[1], STDOUT_FILENO) < 0)
+ goto fail_child;
+ close(pipe_rw[1]);
+ }
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+ execvp(COOPGAMMAD, (char* const*)(args));
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
+ fail_child:
+ saved_errno = errno;
+ perror(NAME_OF_THE_PROCESS);
+ if (write(STDOUT_FILENO, &saved_errno, sizeof(int)) != sizeof(int))
+ perror(NAME_OF_THE_PROCESS);
+ exit(1);
+
+ default:
+ /* Parent */
+ close(pipe_rw[1]), pipe_rw[1] = -1;
+ for (;;) {
+ if (n == size) {
+ new = realloc(msg, size = (n ? (n << 1) : 256));
+ if (!new)
+ goto fail;
+ msg = new;
+ }
+ got = read(pipe_rw[0], msg + n, size - n);
+ if (got < 0) {
+ if (errno == EINTR)
+ continue;
+ goto fail;
+ } else if (got == 0) {
+ break;
+ }
+ n += (size_t)got;
+ }
+ close(pipe_rw[0]), pipe_rw[0] = -1;
+ if (waitpid(pid, &status, 0) < 0)
+ goto fail;
+ if (status) {
+ errno = EINVAL;
+ if (n == sizeof(int) && *(int *)msg)
+ errno = *(int*)msg;
+ }
+ break;
+ }
+
+ if (n == size) {
+ new = realloc(msg, n + 1);
+ if (!new)
+ goto fail;
+ msg = new;
+ }
+ msg[n] = '\0';
+
+ if (strchr(msg, '\0') != msg + n) {
+ errno = EBADMSG;
+ goto fail;
+ }
+
+ return msg;
+
+fail:
+ saved_errno = errno;
+ if (pipe_rw[0] >= 0)
+ close(pipe_rw[0]);
+ if (pipe_rw[1] >= 0)
+ close(pipe_rw[1]);
+ free(msg);
+ errno = saved_errno;
+ return NULL;
+}
+
+
+/**
+ * Get the adjustment method and site
+ *
+ * SIGCHLD must not be ignored or blocked
+ *
+ * @param method The adjustment method, `NULL` for automatic
+ * @param site The site, `NULL` for automatic
+ * @param methodp Output pointer for the selected adjustment method,
+ * which cannot be `NULL`. It is safe to call
+ * this function with this parameter set to `NULL`.
+ * @param sitep Output pointer for the selected site, which will
+ * be `NULL` the method only supports one site or if
+ * `site == NULL` and no site can be selected
+ * automatically. It is safe to call this function
+ * with this parameter set to `NULL`.
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_get_method_and_site(const char *restrict method, const char *restrict site,
+ char **restrict methodp, char **restrict sitep)
+{
+ int saved_errno;
+ char *raw;
+ char *p;
+ char *q;
+
+ raw = libcoopgamma_query(method, site, "-q");
+ if (!raw)
+ return -1;
+
+ if (methodp) *methodp = NULL;
+ if (sitep) *sitep = NULL;
+
+ p = strchr(raw, '\n');
+ if (!p) {
+ errno = EBADMSG;
+ goto fail;
+ }
+ *p++ = '\0';
+
+ if (methodp) {
+ *methodp = malloc(strlen(raw) + 1);
+ if (!*methodp)
+ goto fail;
+ strcpy(*methodp, raw);
+ }
+
+ if (site && *(q = strchr(p, '\0') - 1)) {
+ if (*q != '\n') {
+ errno = EBADMSG;
+ goto fail;
+ }
+ *q = '\0';
+ *sitep = malloc(strlen(p) + 1);
+ if (!*sitep)
+ goto fail;
+ strcpy(*sitep, p);
+ }
+
+ free(raw);
+ return 0;
+
+fail:
+ saved_errno = errno;
+ if (methodp) {
+ free(*methodp);
+ *methodp = NULL;
+ }
+ free(raw);
+ errno = saved_errno;
+ return -1;
+}
+
+
+/**
+ * Get the PID file of the coopgamma server
+ *
+ * SIGCHLD must not be ignored or blocked
+ *
+ * @param method The adjustment method, `NULL` for automatic
+ * @param site The site, `NULL` for automatic
+ * @return The pathname of the server's PID file, `NULL` on error
+ * or if there server does not use PID files. The later
+ * case is detected by checking that `errno` is set to 0.
+ */
+char *
+libcoopgamma_get_pid_file(const char *restrict method, const char *restrict site)
+{
+ char *path;
+ size_t n;
+
+ path = libcoopgamma_get_socket_file(method, site);
+ if (!path)
+ return NULL;
+
+ n = strlen(path);
+ if (n < 7 || strcmp(path + n - 7, ".socket")) {
+ free(path);
+ errno = EBADMSG;
+ return NULL;
+ }
+
+ strcpy(path + n - 7, ".pid");
+ return path;
+}
+
+
+/**
+ * Get the socket file of the coopgamma server
+ *
+ * SIGCHLD must not be ignored or blocked
+ *
+ * @param method The adjustment method, `NULL` for automatic
+ * @param site The site, `NULL` for automatic
+ * @return The pathname of the server's socket, `NULL` on error
+ * or if there server does have its own socket. The later
+ * case is detected by checking that `errno` is set to 0,
+ * and is the case when communicating with a server in a
+ * multi-server display server like mds.
+ */
+char *
+libcoopgamma_get_socket_file(const char *restrict method, const char *restrict site)
+{
+ char *raw;
+ char *p;
+
+ raw = libcoopgamma_query(method, site, "-qq");
+ if (!raw)
+ return NULL;
+
+ p = strchr(raw, '\0') - 1;
+ if (p < raw || *p != '\n') {
+ errno = EBADMSG;
+ goto fail;
+ }
+ *p = '\0';
+ if (!*raw) {
+ errno = EBADMSG;
+ goto fail;
+ }
+
+ return raw;
+fail:
+ free(raw);
+ return NULL;
+}
+
+
+
+/**
+ * Connect to a coopgamma server, and start it if necessary
+ *
+ * Use `libcoopgamma_context_destroy` to disconnect
+ *
+ * SIGCHLD must not be ignored or blocked
+ *
+ * @param method The adjustment method, `NULL` for automatic
+ * @param site The site, `NULL` for automatic
+ * @param ctx The state of the library, must be initialised
+ * @return Zero on success, -1 on error. On error, `errno` is set
+ * to 0 if the server could not be initialised.
+ */
+int
+libcoopgamma_connect(const char *restrict method, const char *restrict site, libcoopgamma_context_t *restrict ctx)
+{
+ const char *(args[6]) = {COOPGAMMAD};
+ struct sockaddr_un address;
+ char* path;
+ int saved_errno;
+ int tries = 0, status;
+ pid_t pid;
+ size_t i = 1;
+
+ ctx->blocking = 1;
+
+ if (method) args[i++] = "-m", args[i++] = method;
+ if (site) args[i++] = "-s", args[i++] = site;
+ args[i] = NULL;
+
+ path = libcoopgamma_get_socket_file(method, site);
+ if (!path)
+ return -1;
+ if (strlen(path) >= sizeof(address.sun_path)) {
+ free(path);
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ address.sun_family = AF_UNIX;
+ strcpy(address.sun_path, path);
+ free(path);
+ if ((ctx->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
+ return -1;
+
+retry:
+ if (connect(ctx->fd, (struct sockaddr *)&address, (socklen_t)sizeof(address)) < 0) {
+ if ((errno == ECONNREFUSED || errno == ENOENT || errno == ENOTDIR) && !tries++) {
+ switch ((pid = fork())) {
+ case -1:
+ goto fail;
+
+ case 0:
+ /* Child */
+ close(ctx->fd);
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+ execvp(COOPGAMMAD, (char *const *)(args));
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
+ perror(NAME_OF_THE_PROCESS);
+ exit(1);
+
+ default:
+ /* Parent */
+ if (waitpid(pid, &status, 0) < 0)
+ goto fail;
+ if (status) {
+ errno = 0;
+ goto fail;
+ }
+ break;
+ }
+ goto retry;
+ }
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ saved_errno = errno;
+ close(ctx->fd);
+ ctx->fd = -1;
+ errno = saved_errno;
+ return -1;
+}
+
+
+/**
+ * By default communication is blocking, this function
+ * can be used to switch between blocking and nonblocking
+ *
+ * After setting the communication to nonblocking,
+ * `libcoopgamma_flush`, `libcoopgamma_synchronise` and
+ * and request-sending functions can fail with EAGAIN and
+ * EWOULDBLOCK. It is safe to continue with `libcoopgamma_flush`
+ * (for `libcoopgamma_flush` it selfand equest-sending functions)
+ * or `libcoopgamma_synchronise` just like EINTR failure.
+ *
+ * @param ctx The state of the library, must be connected
+ * @param nonblocking Nonblocking mode?
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_set_nonblocking(libcoopgamma_context_t *restrict ctx, int nonblocking)
+{
+ int flags = fcntl(ctx->fd, F_GETFL);
+ if (flags == -1)
+ return -1;
+ if (nonblocking)
+ flags |= O_NONBLOCK;
+ else
+ flags &= ~O_NONBLOCK;
+ if (fcntl(ctx->fd, F_SETFL, flags) == -1)
+ return -1;
+ ctx->blocking = !nonblocking;
+ return 0;
+}
+
+
+/**
+ * Send all pending outbound data
+ *
+ * If this function or another function that sends a request
+ * to the server fails with EINTR, call this function to
+ * complete the transfer. The `async` parameter will always
+ * be in a properly configured state if a function fails
+ * with EINTR.
+ *
+ * @param ctx The state of the library, must be connected
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_flush(libcoopgamma_context_t *restrict ctx)
+{
+ ssize_t sent;
+ size_t chunksize = ctx->outbound_head - ctx->outbound_tail;
+ size_t sendsize;
+
+ while (ctx->outbound_tail < ctx->outbound_head) {
+ sendsize = ctx->outbound_head - ctx->outbound_tail;
+ sendsize = sendsize < chunksize ? sendsize : chunksize;
+ sent = send(ctx->fd, ctx->outbound + ctx->outbound_tail, sendsize, MSG_NOSIGNAL);
+ if (sent < 0) {
+ if (errno == EPIPE)
+ errno = ECONNRESET;
+ if (errno != EMSGSIZE)
+ return -1;
+ if (!(chunksize >>= 1))
+ return -1;
+ continue;
+ }
+
+#ifdef DEBUG_MODE
+ fprintf(stderr, "\033[31m");
+ fwrite(ctx->outbound + ctx->outbound_tail, (size_t)sent, 1, stderr);
+ fprintf(stderr, "\033[m");
+ fflush(stderr);
+#endif
+
+ ctx->outbound_tail += (size_t)sent;
+ }
+
+ return 0;
+}
+
+
+/**
+ * Wait for the next message to be received
+ *
+ * @param ctx The state of the library, must be connected
+ * @param pending Information for each pending request
+ * @param n The number of elements in `pending`
+ * @param selected The index of the element in `pending` which corresponds
+ * to the first inbound message, note that this only means
+ * that the message is not for any of the other request,
+ * if the message is corrupt any of the listed requests can
+ * be selected even if it is not for any of the requests.
+ * Functions that parse the message will detect such corruption.
+ * @return Zero on success, -1 on error. If the the message is ignored,
+ * which happens if corresponding `libcoopgamma_async_context_t`
+ * is not listed, -1 is returned and `errno` is set to 0. If -1
+ * is returned, `errno` is set to `ENOTRECOVERABLE` you have
+ * received a corrupt message and the context has been tainted
+ * beyond recover.
+ */
+int
+libcoopgamma_synchronise(libcoopgamma_context_t *restrict ctx, libcoopgamma_async_context_t *restrict pending,
+ size_t n, size_t *restrict selected)
+{
+ char temp[3 * sizeof(size_t) + 1];
+ ssize_t got;
+ size_t i;
+ char *p;
+ char *line;
+ char *value;
+ struct pollfd pollfd;
+ size_t new_size;
+ void *new;
+
+ if (ctx->inbound_head == ctx->inbound_tail) {
+ ctx->inbound_head = ctx->inbound_tail = ctx->curline = 0;
+ } else if (ctx->inbound_tail > 0) {
+ memmove(ctx->inbound, ctx->inbound + ctx->inbound_tail, ctx->inbound_head -= ctx->inbound_tail);
+ ctx->curline -= ctx->inbound_tail;
+ ctx->inbound_tail = 0;
+ }
+
+ pollfd.fd = ctx->fd;
+ pollfd.events = POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI;
+
+ if (ctx->inbound_head)
+ goto skip_recv;
+ for (;;) {
+ if (ctx->inbound_head == ctx->inbound_size) {
+ new_size = ctx->inbound_size ? (ctx->inbound_size << 1) : 1024;
+ new = realloc(ctx->inbound, new_size);
+ if (!new)
+ return -1;
+ ctx->inbound = new;
+ ctx->inbound_size = new_size;
+ }
+
+ if (ctx->blocking) {
+ pollfd.revents = 0;
+ if (poll(&pollfd, (nfds_t)1, -1) < 0)
+ return -1;
+ }
+ got = recv(ctx->fd, ctx->inbound + ctx->inbound_head, ctx->inbound_size - ctx->inbound_head, 0);
+ if (got <= 0) {
+ if (got == 0)
+ errno = ECONNRESET;
+ return -1;
+ }
+
+#ifdef DEBUG_MODE
+ fprintf(stderr, "\033[32m");
+ fwrite(ctx->inbound + ctx->inbound_head, (size_t)got, 1, stderr);
+ fprintf(stderr, "\033[m");
+ fflush(stderr);
+#endif
+
+ ctx->inbound_head += (size_t)got;
+
+ skip_recv:
+ while (!ctx->have_all_headers) {
+ line = ctx->inbound + ctx->curline;
+ p = memchr(line, '\n', ctx->inbound_head - ctx->curline);
+ if (!p)
+ break;
+ if (memchr(line, '\0', (size_t)(p - line)) != NULL)
+ ctx->bad_message = 1;
+ *p++ = '\0';
+ ctx->curline = (size_t)(p - ctx->inbound);
+ if (!*line) {
+ ctx->have_all_headers = 1;
+ } else if (strstr(line, "In response to: ") == line) {
+ value = line + (sizeof("In response to: ") - 1);
+ ctx->in_response_to = (uint32_t)atol(value);
+ } else if (strstr(line, "Length: ") == line) {
+ value = line + (sizeof("Length: ") - 1);
+ ctx->length = (size_t)atol(value);
+ sprintf(temp, "%zu", ctx->length);
+ if (strcmp(value, temp))
+ goto fatal;
+ }
+ }
+
+ if (ctx->have_all_headers && ctx->inbound_head >= ctx->curline + ctx->length) {
+ ctx->curline += ctx->length;
+ if (ctx->bad_message) {
+ ctx->bad_message = 0;
+ ctx->have_all_headers = 0;
+ ctx->length = 0;
+ ctx->inbound_tail = ctx->curline;
+ errno = EBADMSG;
+ return -1;
+ }
+ for (i = 0; i < n; i++) {
+ if (pending[i].message_id == ctx->in_response_to) {
+ *selected = i;
+ return 0;
+ }
+ }
+ *selected = 0;
+ ctx->bad_message = 0;
+ ctx->have_all_headers = 0;
+ ctx->length = 0;
+ ctx->inbound_tail = ctx->curline;
+ errno = 0;
+ return -1;
+ }
+ }
+
+fatal:
+ errno = ENOTRECOVERABLE;
+ return -1;
+}
+
+
+/**
+ * Send a message to the server and wait for response
+ *
+ * @param resp:char** Output parameter for the response,
+ * will be NUL-terminated
+ * @param ctx:libcoopgamma_context_t* The state of the library
+ * @param payload:void* Data to append to the end of the message
+ * @param payload_size:size_t Byte-size of `payload`
+ * @param format:string-literal Message formatting string
+ * @param ... Message formatting arguments
+ *
+ * On error, the macro goes to `fail`.
+ */
+#define SEND_MESSAGE(ctx, payload, payload_size, format, ...)\
+ do {\
+ ssize_t n__;\
+ char *msg__;\
+ snprintf(NULL, (size_t)0, format "%zn", __VA_ARGS__, &n__);\
+ msg__ = malloc((size_t)n__ + (payload_size) + (size_t)1);\
+ if (!msg__)\
+ goto fail;\
+ sprintf(msg__, format, __VA_ARGS__);\
+ if (payload)\
+ memcpy(msg__ + n__, (payload), (payload_size));\
+ if (send_message((ctx), msg__, (size_t)n__ + (payload_size)) < 0)\
+ goto fail;\
+ } while (0)
+
+
+/**
+ * Send a message to the server and wait for response
+ *
+ * @param ctx The state of the library
+ * @param msg The message to send
+ * @param n The length of `msg`
+ * @return Zero on success, -1 on error
+ */
+static int
+send_message(libcoopgamma_context_t *restrict ctx, char *msg, size_t n)
+{
+ void *new;
+ if (ctx->outbound_head == ctx->outbound_tail) {
+ free(ctx->outbound);
+ ctx->outbound = msg;
+ ctx->outbound_tail = 0;
+ ctx->outbound_head = n;
+ ctx->outbound_size = n;
+ } else {
+ if (ctx->outbound_head + n > ctx->outbound_size) {
+ memmove(ctx->outbound, ctx->outbound + ctx->outbound_tail, ctx->outbound_head -= ctx->outbound_tail);
+ ctx->outbound_tail = 0;
+ }
+ if (ctx->outbound_head + n > ctx->outbound_size) {
+ new = realloc(ctx->outbound, ctx->outbound_head + n);
+ if (!new) {
+ free(msg);
+ return -1;
+ }
+ ctx->outbound = new;
+ ctx->outbound_size = ctx->outbound_head + n;
+ }
+ memcpy(ctx->outbound + ctx->outbound_head, msg, n);
+ ctx->outbound_head += n;
+ free(msg);
+ }
+ ctx->message_id += 1;
+ return libcoopgamma_flush(ctx);
+}
+
+
+/**
+ * Get the next header of the inbound message
+ *
+ * All headers must be read before the payload is read
+ *
+ * @param ctx The state of the library, must be connected
+ * @return The next header line, can never be `NULL`,
+ * the empty string marks the end of the headers.
+ * This memory segment must not be freed.
+ */
+static char *
+next_header(libcoopgamma_context_t *restrict ctx)
+{
+ char *rc = ctx->inbound + ctx->inbound_tail;
+ ctx->inbound_tail += strlen(rc) + 1;
+ return rc;
+}
+
+
+/**
+ * Get the payload of the inbound message
+ *
+ * Calling this function marks that the inbound message
+ * has been fully ready. You must call this function
+ * even if you do not expect a payload
+ *
+ * @param ctx The state of the library, must be connected
+ * @param n Output parameter for the size of the payload
+ * @return The payload (not NUL-terminated), `NULL` if
+ * there is no payload. Failure is impossible.
+ * This memory segment must not be freed.
+ */
+static char *
+next_payload(libcoopgamma_context_t *restrict ctx, size_t *n)
+{
+ char *rc;
+ ctx->have_all_headers = 0;
+ if ((*n = ctx->length)) {
+ rc = ctx->inbound + ctx->inbound_tail;
+ ctx->inbound_tail += *n;
+ ctx->length = 0;
+ return rc;
+ }
+ return NULL;
+}
+
+
+/**
+ * Tell the library that you will not be parsing a receive message
+ *
+ * @param ctx The state of the library, must be connected
+ */
+void
+libcoopgamma_skip_message(libcoopgamma_context_t *restrict ctx)
+{
+ size_t _n;
+ while (*next_header(ctx));
+ (void) next_payload(ctx, &_n);
+}
+
+
+/**
+ * Check whether the server sent an error, if so copy it to `ctx`
+ *
+ * This function will also reports EBADMSG if the message ID
+ * that the message is a response to does not match the request
+ * information, or if it is missing
+ *
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request
+ * @return 1 if the server sent an error (even indicating success),
+ * 0 on success, -1 on failure. Information about failure
+ * is copied `ctx`.
+ */
+static int
+check_error(libcoopgamma_context_t *restrict ctx, libcoopgamma_async_context_t *restrict async)
+{
+ char temp[3 * sizeof(uint64_t) + 1];
+ size_t old_tail = ctx->inbound_tail;
+ char *line;
+ char *value;
+ int command_ok = 0;
+ int have_in_response_to = 0;
+ int have_error = 0;
+ int bad = 0;
+ char *payload;
+ size_t n;
+
+ for (;;) {
+ line = next_header(ctx);
+ value = strchr(line, ':') + 2;
+ if (!*line) {
+ break;
+ } else if (!strcmp(line, "Command: error")) {
+ command_ok = 1;
+ } else if (strstr(line, "In response to: ") == line) {
+ uint32_t id = (uint32_t)atol(value);
+ have_in_response_to = 1 + !!have_in_response_to;
+ if (id != async->message_id) {
+ bad = 1;
+ } else {
+ sprintf(temp, "%" PRIu32, id);
+ if (strcmp(value, temp))
+ bad = 1;
+ }
+ } else if (strstr(line, "Error: ") == line) {
+ have_error = 1 + !!have_error;
+ ctx->error.server_side = 1;
+ ctx->error.custom = (strstr(value, "custom") == value);
+ if (ctx->error.custom) {
+ if (value[6] == '\0') {
+ ctx->error.number = 0;
+ continue;
+ } else if (value[6] != ' ') {
+ bad = 1;
+ continue;
+ }
+ value += 7;
+ }
+ ctx->error.number = (uint64_t)atoll(value);
+ sprintf(temp, "%" PRIu64, ctx->error.number);
+ if (strcmp(value, temp))
+ bad = 1;
+ }
+ }
+
+ if (!command_ok) {
+ ctx->inbound_tail = old_tail;
+ return 0;
+ }
+
+ payload = next_payload(ctx, &n);
+ if (payload) {
+ if (memchr(payload, '\0', n) || payload[n - 1] != '\n')
+ goto badmsg;
+ ctx->error.description = malloc(n);
+ if (ctx->error.description == NULL)
+ goto fail;
+ memcpy(ctx->error.description, payload, n - 1);
+ ctx->error.description[n - 1] = '\0';
+ }
+
+ if (bad || have_in_response_to != 1 || have_error != 1)
+ goto badmsg;
+
+ return 1;
+
+badmsg:
+ errno = EBADMSG;
+fail:
+ copy_errno(ctx);
+ return -1;
+}
+
+
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull"
+#endif
+
+
+
+/**
+ * List all available CRTC:s, send request part
+ *
+ * Cannot be used before connecting to the server
+ *
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request, that is needed to
+ * identify and parse the response, is stored here
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_get_crtcs_send(libcoopgamma_context_t *restrict ctx, libcoopgamma_async_context_t *restrict async)
+{
+ async->message_id = ctx->message_id;
+ SEND_MESSAGE(ctx, NULL, (size_t)0,
+ "Command: enumerate-crtcs\n"
+ "Message ID: %" PRIu32 "\n"
+ "\n",
+ ctx->message_id);
+
+ return 0;
+fail:
+ copy_errno(ctx);
+ return -1;
+}
+
+
+/**
+ * List all available CRTC:s, receive response part
+ *
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request
+ * @return A `NULL`-terminated list of names. You should only free
+ * the outer pointer, inner pointers are subpointers of the
+ * outer pointer and cannot be freed. `NULL` on error, in
+ * which case `ctx->error` (rather than `errno`) is read
+ * for information about the error.
+ */
+char **
+libcoopgamma_get_crtcs_recv(libcoopgamma_context_t *restrict ctx, libcoopgamma_async_context_t *restrict async)
+{
+ char *line;
+ char *payload;
+ char *end;
+ int command_ok = 0;
+ size_t i, n, lines, len, length;
+ char **rc;
+
+ if (check_error(ctx, async))
+ return NULL;
+
+ for (;;) {
+ line = next_header(ctx);
+ if (!*line)
+ break;
+ else if (!strcmp(line, "Command: crtc-enumeration"))
+ command_ok = 1;
+ }
+
+ payload = next_payload(ctx, &n);
+
+ if (!command_ok || (n > 0 && payload[n - 1] != '\n')) {
+ errno = EBADMSG;
+ copy_errno(ctx);
+ return NULL;
+ }
+
+ line = payload;
+ end = payload + n;
+ lines = length = 0;
+ while (line != end) {
+ lines += 1;
+ length += len = (size_t)(strchr(line, '\n') + 1 - line);
+ line += len;
+ line[-1] = '\0';
+ }
+
+ rc = malloc((lines + 1) * sizeof(char *) + length);
+ if (!rc) {
+ copy_errno(ctx);
+ return NULL;
+ }
+
+ line = ((char *)rc) + (lines + 1) * sizeof(char *);
+ memcpy(line, payload, length);
+ rc[lines] = NULL;
+ for (i = 0; i < lines; i++) {
+ rc[i] = line;
+ line = strchr(line, '\0') + 1;
+ }
+
+ return rc;
+}
+
+
+/**
+ * List all available CRTC:s, synchronous version
+ *
+ * This is a synchronous request function, as such,
+ * you have to ensure that communication is blocking
+ * (default), and that there are not asynchronous
+ * requests waiting, it also means that EINTR:s are
+ * silently ignored and there no wait to cancel the
+ * operation without disconnection from the server
+ *
+ * @param ctx The state of the library, must be connected
+ * @return A `NULL`-terminated list of names. You should only free
+ * the outer pointer, inner pointers are subpointers of the
+ * outer pointer and cannot be freed. `NULL` on error, in
+ * which case `ctx->error` (rather than `errno`) is read
+ * for information about the error.
+ */
+char **
+libcoopgamma_get_crtcs_sync(libcoopgamma_context_t *restrict ctx)
+{
+ SYNC_CALL(libcoopgamma_get_crtcs_send(ctx, &async),
+ libcoopgamma_get_crtcs_recv(ctx, &async), (copy_errno(ctx), NULL));
+}
+
+
+
+/**
+ * Retrieve information about a CRTC:s gamma ramps, send request part
+ *
+ * Cannot be used before connecting to the server
+ *
+ * @param crtc The name of the CRTC
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request, that is needed to
+ * identify and parse the response, is stored here
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_get_gamma_info_send(const char *restrict crtc, libcoopgamma_context_t *restrict ctx,
+ libcoopgamma_async_context_t *restrict async)
+{
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull-compare"
+#endif
+ if (crtc == NULL || strchr(crtc, '\n')) {
+ errno = EINVAL;
+ goto fail;
+ }
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic pop
+#endif
+
+ async->message_id = ctx->message_id;
+ SEND_MESSAGE(ctx, NULL, (size_t)0,
+ "Command: get-gamma-info\n"
+ "Message ID: %" PRIu32 "\n"
+ "CRTC: %s\n"
+ "\n",
+ ctx->message_id, crtc);
+
+ return 0;
+fail:
+ copy_errno(ctx);
+ return 0;
+}
+
+
+/**
+ * Retrieve information about a CRTC:s gamma ramps, receive response part
+ *
+ * @param info Output parameter for the information, must be initialised
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request
+ * @return Zero on success, -1 on error, in which case `ctx->error`
+ * (rather than `errno`) is read for information about the error
+ */
+int
+libcoopgamma_get_gamma_info_recv(libcoopgamma_crtc_info_t *restrict info, libcoopgamma_context_t *restrict ctx,
+ libcoopgamma_async_context_t *restrict async)
+{
+ char temp[3 * sizeof(size_t) + 1];
+ char *line;
+ char *value;
+ size_t _n;
+ int have_cooperative = 0, have_gamma_support = 0, have_colourspace = 0;
+ int have_depth = 0, have_white_x = 0, have_white_y = 0;
+ int have_red_size = 0, have_red_x = 0, have_red_y = 0;
+ int have_green_size = 0, have_green_x = 0, have_green_y = 0;
+ int have_blue_size = 0, have_blue_x = 0, have_blue_y = 0;
+ int bad = 0, r = 0, g = 0, b = 0, x = 0;
+ size_t *outz;
+ unsigned *outu;
+ int *have;
+
+ if (check_error(ctx, async))
+ return -1;
+
+ info->cooperative = 0; /* Should be in the response, but ... */
+ info->colourspace = LIBCOOPGAMMA_UNKNOWN;
+
+ for (;;) {
+ line = next_header(ctx);
+ value = strchr(line, ':') + 2;
+ if (!*line) {
+ break;
+ } else if (strstr(line, "Cooperative: ") == line) {
+ have_cooperative = 1 + !!have_cooperative;
+ if (!strcmp(value, "yes")) info->cooperative = 1;
+ else if (!strcmp(value, "no")) info->cooperative = 0;
+ else
+ bad = 1;
+ } else if (strstr(line, "Depth: ") == line) {
+ have_depth = 1 + !!have_depth;
+ if (!strcmp(value, "8")) info->depth = LIBCOOPGAMMA_UINT8;
+ else if (!strcmp(value, "16")) info->depth = LIBCOOPGAMMA_UINT16;
+ else if (!strcmp(value, "32")) info->depth = LIBCOOPGAMMA_UINT32;
+ else if (!strcmp(value, "64")) info->depth = LIBCOOPGAMMA_UINT64;
+ else if (!strcmp(value, "f")) info->depth = LIBCOOPGAMMA_FLOAT;
+ else if (!strcmp(value, "d")) info->depth = LIBCOOPGAMMA_DOUBLE;
+ else
+ bad = 1;
+ } else if (strstr(line, "Gamma support: ") == line) {
+ have_gamma_support = 1 + !!have_gamma_support;
+ if (!strcmp(value, "yes")) info->supported = LIBCOOPGAMMA_YES;
+ else if (!strcmp(value, "no")) info->supported = LIBCOOPGAMMA_NO;
+ else if (!strcmp(value, "maybe")) info->supported = LIBCOOPGAMMA_MAYBE;
+ else
+ bad = 1;
+ } else if ((r = (strstr(line, "Red size: ") == line)) ||
+ (g = (strstr(line, "Green size: ") == line)) ||
+ strstr(line, "Blue size: ") == line) {
+ if (r) have_red_size = 1 + !!have_red_size, outz = &info->red_size;
+ else if (g) have_green_size = 1 + !!have_green_size, outz = &info->green_size;
+ else have_blue_size = 1 + !!have_blue_size, outz = &info->blue_size;
+ *outz = (size_t)atol(value);
+ sprintf(temp, "%zu", *outz);
+ if (strcmp(value, temp))
+ bad = 1;
+ } else if ((x = r = (strstr(line, "Red x: ") == line)) ||
+ (r = (strstr(line, "Red y: ") == line)) ||
+ (x = g = (strstr(line, "Green x: ") == line)) ||
+ (g = (strstr(line, "Green y: ") == line)) ||
+ (x = b = (strstr(line, "Blue x: ") == line)) ||
+ (b = (strstr(line, "Blue y: ") == line)) ||
+ (x = (strstr(line, "White x: ") == line)) ||
+ strstr(line, "White y: ") == line) {
+ if (r && x) have = &have_red_x, outu = &info->red_x;
+ else if (r) have = &have_red_y, outu = &info->red_y;
+ else if (g && x) have = &have_green_x, outu = &info->green_x;
+ else if (g) have = &have_green_y, outu = &info->green_y;
+ else if (b && x) have = &have_blue_x, outu = &info->blue_x;
+ else if (b) have = &have_blue_y, outu = &info->blue_y;
+ else if (x) have = &have_white_x, outu = &info->white_x;
+ else have = &have_white_y, outu = &info->white_y;
+ *have = 1 + !!*have;
+ *outu = (unsigned)atoi(value);
+ sprintf(temp, "%u", *outu);
+ if (strcmp(value, temp))
+ bad = 1;
+ } else if (strstr(line, "Colour space: ") == line) {
+ have_colourspace = 1 + !!have_colourspace;
+ if (!strcmp(value, "sRGB")) info->colourspace = LIBCOOPGAMMA_SRGB;
+ else if (!strcmp(value, "RGB")) info->colourspace = LIBCOOPGAMMA_RGB;
+ else if (!strcmp(value, "non-RGB")) info->colourspace = LIBCOOPGAMMA_NON_RGB;
+ else if (!strcmp(value, "grey")) info->colourspace = LIBCOOPGAMMA_GREY;
+ else
+ info->colourspace = LIBCOOPGAMMA_UNKNOWN;
+ }
+ }
+
+ (void) next_payload(ctx, &_n);
+
+ info->have_gamut = (have_red_x && have_green_x && have_blue_x && have_white_x &&
+ have_red_y && have_green_y && have_blue_y && have_white_y);
+
+ if (bad || have_gamma_support != 1 || have_red_x > 1 || have_red_y > 1 ||
+ have_green_x > 1 || have_green_y > 1 || have_blue_x > 1 || have_blue_y > 1 ||
+ have_white_x > 1 || have_white_y > 1 || have_colourspace > 1) {
+ errno = EBADMSG;
+ copy_errno(ctx);
+ return -1;
+ }
+ if (info->supported != LIBCOOPGAMMA_NO) {
+ if (have_cooperative > 1 || have_depth != 1 || have_gamma_support != 1 ||
+ have_red_size != 1 || have_green_size != 1 || have_blue_size != 1) {
+ errno = EBADMSG;
+ copy_errno(ctx);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+/**
+ * Retrieve information about a CRTC:s gamma ramps, synchronous version
+ *
+ * This is a synchronous request function, as such,
+ * you have to ensure that communication is blocking
+ * (default), and that there are not asynchronous
+ * requests waiting, it also means that EINTR:s are
+ * silently ignored and there no wait to cancel the
+ * operation without disconnection from the server
+ *
+ * @param crtc The name of the CRTC
+ * @param info Output parameter for the information, must be initialised
+ * @param ctx The state of the library, must be connected
+ * @return Zero on success, -1 on error, in which case `ctx->error`
+ * (rather than `errno`) is read for information about the error
+ */
+int
+libcoopgamma_get_gamma_info_sync(const char *restrict ctrc, libcoopgamma_crtc_info_t *restrict info,
+ libcoopgamma_context_t *restrict ctx)
+{
+ SYNC_CALL(libcoopgamma_get_gamma_info_send(ctrc, ctx, &async),
+ libcoopgamma_get_gamma_info_recv(info, ctx, &async), (copy_errno(ctx), -1));
+}
+
+
+
+/**
+ * Retrieve the current gamma ramp adjustments, send request part
+ *
+ * Cannot be used before connecting to the server
+ *
+ * @param query The query to send
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request, that is needed to
+ * identify and parse the response, is stored here
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_get_gamma_send(const libcoopgamma_filter_query_t *restrict query, libcoopgamma_context_t *restrict ctx,
+ libcoopgamma_async_context_t *restrict async)
+{
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull-compare"
+#endif
+ if (!query || !query->crtc || strchr(query->crtc, '\n')) {
+ errno = EINVAL;
+ goto fail;
+ }
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic pop
+#endif
+
+ async->message_id = ctx->message_id;
+ async->coalesce = query->coalesce;
+ SEND_MESSAGE(ctx, NULL, (size_t)0,
+ "Command: get-gamma\n"
+ "Message ID: %" PRIu32 "\n"
+ "CRTC: %s\n"
+ "Coalesce: %s\n"
+ "High priority: %" PRIi64 "\n"
+ "Low priority: %" PRIi64 "\n"
+ "\n",
+ ctx->message_id, query->crtc, query->coalesce ? "yes" : "no",
+ query->high_priority, query->low_priority);
+
+ return 0;
+fail:
+ copy_errno(ctx);
+ return -1;
+}
+
+
+/**
+ * Retrieve the current gamma ramp adjustments, receive response part
+ *
+ * @param table Output for the response, must be initialised
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request
+ * @return Zero on success, -1 on error, in which case `ctx->error`
+ * (rather than `errno`) is read for information about the error
+ */
+int
+libcoopgamma_get_gamma_recv(libcoopgamma_filter_table_t *restrict table, libcoopgamma_context_t *restrict ctx,
+ libcoopgamma_async_context_t *restrict async)
+{
+ char temp[3 * sizeof(size_t) + 1];
+ char *line;
+ char *value;
+ char *payload;
+ size_t i, n, width, clutsize;
+ int have_depth = 0;
+ int have_red_size = 0;
+ int have_green_size = 0;
+ int have_blue_size = 0;
+ int have_tables = 0;
+ int bad = 0, r = 0, g = 0;
+ size_t *out;
+ size_t off, len;
+
+ if (check_error(ctx, async))
+ return -1;
+
+ libcoopgamma_filter_table_destroy(table);
+
+ for (;;) {
+ line = next_header(ctx);
+ value = strchr(line, ':') + 2;
+ if (!*line) {
+ break;
+ } else if (strstr(line, "Depth: ") == line) {
+ have_depth = 1 + !!have_depth;
+ if (!strcmp(value, "8")) table->depth = LIBCOOPGAMMA_UINT8;
+ else if (!strcmp(value, "16")) table->depth = LIBCOOPGAMMA_UINT16;
+ else if (!strcmp(value, "32")) table->depth = LIBCOOPGAMMA_UINT32;
+ else if (!strcmp(value, "64")) table->depth = LIBCOOPGAMMA_UINT64;
+ else if (!strcmp(value, "f")) table->depth = LIBCOOPGAMMA_FLOAT;
+ else if (!strcmp(value, "d")) table->depth = LIBCOOPGAMMA_DOUBLE;
+ else
+ bad = 1;
+ } else if ((r = (strstr(line, "Red size: ") == line)) ||
+ (g = (strstr(line, "Green size: ") == line)) ||
+ strstr(line, "Blue size: ") == line) {
+ if (r) have_red_size = 1 + !!have_red_size, out = &table->red_size;
+ else if (g) have_green_size = 1 + !!have_green_size, out = &table->green_size;
+ else have_blue_size = 1 + !!have_blue_size, out = &table->blue_size;
+ *out = (size_t)atol(value);
+ sprintf(temp, "%zu", *out);
+ if (strcmp(value, temp))
+ bad = 1;
+ } else if (strstr(line, "Tables: ") == line) {
+ have_tables = 1 + have_tables;
+ table->filter_count = (size_t)atol(value);
+ sprintf(temp, "%zu", table->filter_count);
+ if (strcmp(value, temp))
+ bad = 1;
+ }
+ }
+
+ payload = next_payload(ctx, &n);
+
+ if (bad || have_depth != 1 || have_red_size != 1 || have_green_size != 1 ||
+ have_blue_size != 1 || (async->coalesce ? have_tables > 1 : !have_tables) ||
+ ((!payload || !n) && (async->coalesce || table->filter_count > 0)) ||
+ (n > 0 && have_tables && !table->filter_count) ||
+ (async->coalesce && have_tables && table->filter_count != 1))
+ goto bad;
+
+ switch (table->depth) {
+ case LIBCOOPGAMMA_FLOAT: width = sizeof(float); break;
+ case LIBCOOPGAMMA_DOUBLE: width = sizeof(double); break;
+ default: INTEGRAL_DEPTHS
+ if (table->depth <= 0 || (table->depth & 7))
+ goto bad;
+ width = (size_t)(table->depth / 8);
+ break;
+ }
+
+ clutsize = table->red_size + table->green_size + table->blue_size;
+ clutsize *= width;
+
+ if (async->coalesce) {
+ if (n != clutsize)
+ goto bad;
+ table->filters = malloc(sizeof(*(table->filters)));
+ if (!table->filters)
+ goto fail;
+ table->filters->priority = 0;
+ table->filters->class = NULL;
+ table->filters->ramps.u8.red_size = table->red_size;
+ table->filters->ramps.u8.green_size = table->green_size;
+ table->filters->ramps.u8.blue_size = table->blue_size;
+ if (libcoopgamma_ramps_initialise_(&table->filters->ramps, width) < 0)
+ goto fail;
+ memcpy(table->filters->ramps.u8.red, payload, clutsize);
+ table->filter_count = 1;
+ } else if (!table->filter_count) {
+ table->filters = NULL;
+ } else {
+ off = 0;
+ table->filters = calloc(table->filter_count, sizeof(*table->filters));
+ if (!table->filters)
+ goto fail;
+ for (i = 0; i < table->filter_count; i++) {
+ if (off + sizeof(int64_t) > n)
+ goto bad;
+ table->filters[i].priority = *(int64_t *)(payload + off);
+ off += sizeof(int64_t);
+ if (!memchr(payload + off, '\0', n - off))
+ goto bad;
+ len = strlen(payload + off) + 1;
+ table->filters[i].class = malloc(len);
+ if (!table->filters[i].class)
+ goto fail;
+ memcpy(table->filters[i].class, payload + off, len);
+ off += len;
+ if (off + clutsize > n)
+ goto bad;
+ table->filters[i].ramps.u8.red_size = table->red_size;
+ table->filters[i].ramps.u8.green_size = table->green_size;
+ table->filters[i].ramps.u8.blue_size = table->blue_size;
+ if (libcoopgamma_ramps_initialise_(&(table->filters[i].ramps), width) < 0)
+ goto fail;
+ memcpy(table->filters->ramps.u8.red, payload + off, clutsize);
+ off += clutsize;
+ }
+ if (off != n)
+ goto bad;
+ }
+
+ return 0;
+bad:
+ errno = EBADMSG;
+fail:
+ copy_errno(ctx);
+ return -1;
+}
+
+
+/**
+ * Retrieve the current gamma ramp adjustments, synchronous version
+ *
+ * This is a synchronous request function, as such,
+ * you have to ensure that communication is blocking
+ * (default), and that there are not asynchronous
+ * requests waiting, it also means that EINTR:s are
+ * silently ignored and there no wait to cancel the
+ * operation without disconnection from the server
+ *
+ * @param query The query to send
+ * @param table Output for the response, must be initialised
+ * @param ctx The state of the library, must be connected
+ * @return Zero on success, -1 on error, in which case `ctx->error`
+ * (rather than `errno`) is read for information about the error
+ */
+int
+libcoopgamma_get_gamma_sync(const libcoopgamma_filter_query_t *restrict query, libcoopgamma_filter_table_t *restrict table,
+ libcoopgamma_context_t *restrict ctx)
+{
+ SYNC_CALL(libcoopgamma_get_gamma_send(query, ctx, &async),
+ libcoopgamma_get_gamma_recv(table, ctx, &async), (copy_errno(ctx), -1));
+}
+
+
+
+/**
+ * Apply, update, or remove a gamma ramp adjustment, send request part
+ *
+ * Cannot be used before connecting to the server
+ *
+ * @param filter The filter to apply, update, or remove, gamma ramp meta-data must match the CRTC's
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request, that is needed to
+ * identify and parse the response, is stored here
+ * @return Zero on success, -1 on error
+ */
+int
+libcoopgamma_set_gamma_send(const libcoopgamma_filter_t *restrict filter, libcoopgamma_context_t *restrict ctx,
+ libcoopgamma_async_context_t *restrict async)
+{
+ const void *payload = NULL;
+ const char *lifespan;
+ char priority[sizeof("Priority: \n") + 3 * sizeof(int64_t)] = {'\0'};
+ char length [sizeof("Length: \n") + 3 * sizeof(size_t) ] = {'\0'};
+ size_t payload_size = 0, stopwidth = 0;
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull-compare"
+#endif
+ if (!filter || !filter->crtc || strchr(filter->crtc, '\n') || !filter->class || strchr(filter->class, '\n')) {
+ errno = EINVAL;
+ goto fail;
+ }
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic pop
+#endif
+
+ switch (filter->lifespan) {
+ case LIBCOOPGAMMA_REMOVE: lifespan = "remove"; break;
+ case LIBCOOPGAMMA_UNTIL_DEATH: lifespan = "until-death"; break;
+ case LIBCOOPGAMMA_UNTIL_REMOVAL: lifespan = "until-removal"; break;
+ default:
+ errno = EINVAL;
+ goto fail;
+ }
+
+ if (filter->lifespan != LIBCOOPGAMMA_REMOVE) {
+ switch (filter->depth) {
+ case LIBCOOPGAMMA_FLOAT: stopwidth = sizeof(float); break;
+ case LIBCOOPGAMMA_DOUBLE: stopwidth = sizeof(double); break;
+ default: INTEGRAL_DEPTHS
+ if (filter->depth <= 0 || (filter->depth & 7)) {
+ errno = EINVAL;
+ goto fail;
+ }
+ stopwidth = (size_t)(filter->depth / 8);
+ break;
+ }
+
+ payload_size = filter->ramps.u8.red_size;
+ payload_size += filter->ramps.u8.green_size;
+ payload_size += filter->ramps.u8.blue_size;
+ payload_size *= stopwidth;
+ payload = filter->ramps.u8.red;
+ sprintf(priority, "Priority: %" PRIi64 "\n", filter->priority);
+ sprintf(length, "Length: %zu\n", payload_size);
+ }
+
+ async->message_id = ctx->message_id;
+ SEND_MESSAGE(ctx, payload, payload_size,
+ "Command: set-gamma\n"
+ "Message ID: %" PRIu32 "\n"
+ "CRTC: %s\n"
+ "Class: %s\n"
+ "Lifespan: %s\n"
+ "%s"
+ "%s"
+ "\n",
+ ctx->message_id, filter->crtc, filter->class, lifespan, priority, length);
+
+ return 0;
+fail:
+ copy_errno(ctx);
+ return -1;
+}
+
+
+/**
+ * Apply, update, or remove a gamma ramp adjustment, receive response part
+ *
+ * @param ctx The state of the library, must be connected
+ * @param async Information about the request
+ * @return Zero on success, -1 on error, in which case `ctx->error`
+ * (rather than `errno`) is read for information about the error
+ */
+int
+libcoopgamma_set_gamma_recv(libcoopgamma_context_t *restrict ctx, libcoopgamma_async_context_t *restrict async)
+{
+ size_t _n = 0;
+
+ if (check_error(ctx, async))
+ return -(ctx->error.custom || ctx->error.number);
+
+ while (*next_header(ctx));
+ (void) next_payload(ctx, &_n);
+
+ errno = EBADMSG;
+ copy_errno(ctx);
+ return -1;
+}
+
+
+/**
+ * Apply, update, or remove a gamma ramp adjustment, synchronous version
+ *
+ * This is a synchronous request function, as such,
+ * you have to ensure that communication is blocking
+ * (default), and that there are not asynchronous
+ * requests waiting, it also means that EINTR:s are
+ * silently ignored and there no wait to cancel the
+ * operation without disconnection from the server
+ *
+ * @param filter The filter to apply, update, or remove, gamma ramp meta-data must match the CRTC's
+ * @param depth The datatype for the stops in the gamma ramps, must match the CRTC's
+ * @param ctx The state of the library, must be connected
+ * @return Zero on success, -1 on error, in which case `ctx->error`
+ * (rather than `errno`) is read for information about the error
+ */
+int
+libcoopgamma_set_gamma_sync(const libcoopgamma_filter_t *restrict filter, libcoopgamma_context_t *restrict ctx)
+{
+ SYNC_CALL(libcoopgamma_set_gamma_send(filter, ctx, &async),
+ libcoopgamma_set_gamma_recv(ctx, &async), (copy_errno(ctx), -1));
+}
+
+
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
diff --git a/src/libcoopgamma.h b/libcoopgamma.h
index 723d5a3..5f5e800 100644
--- a/src/libcoopgamma.h
+++ b/libcoopgamma.h
@@ -1,40 +1,21 @@
-/**
- * libcoopgamma -- Library for interfacing with cooperative gamma servers
- * Copyright (C) 2016 Mattias Andrée (maandree@kth.se)
- *
- * This library 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 3 of the License, or
- * (at your option) any later version.
- *
- * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
- */
+/* See LICENSE file for copyright and license details. */
#ifndef LIBCOOPGAMMA_H
#define LIBCOOPGAMMA_H
-
-
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
-
#if defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdocumentation"
#endif
#if defined(__GNUC__) && !defined(__clang__)
-# define LIBCOOPGAMMA_GCC_ONLY(...) __VA_ARGS__
+# define LIBCOOPGAMMA_GCC_ONLY(...) __VA_ARGS__
#else
-# define LIBCOOPGAMMA_GCC_ONLY(...) /* ignore */
+# define LIBCOOPGAMMA_GCC_ONLY(...) /* ignore */
#endif
@@ -171,30 +152,29 @@
* Values used to indicate the support
* for gamma adjustments
*/
-typedef enum libcoopgamma_support
-{
- /**
- * Gamma adjustments are not supported
- *
- * This value will always be 0
- */
- LIBCOOPGAMMA_NO = 0,
-
- /**
- * Don't know whether gamma
- * adjustments are supported
- *
- * This value will always be 1
- */
- LIBCOOPGAMMA_MAYBE = 1,
-
- /**
- * Gamma adjustments are supported
- *
- * This value will always be 2
- */
- LIBCOOPGAMMA_YES = 2
-
+typedef enum libcoopgamma_support {
+ /**
+ * Gamma adjustments are not supported
+ *
+ * This value will always be 0
+ */
+ LIBCOOPGAMMA_NO = 0,
+
+ /**
+ * Don't know whether gamma
+ * adjustments are supported
+ *
+ * This value will always be 1
+ */
+ LIBCOOPGAMMA_MAYBE = 1,
+
+ /**
+ * Gamma adjustments are supported
+ *
+ * This value will always be 2
+ */
+ LIBCOOPGAMMA_YES = 2
+
} libcoopgamma_support_t;
@@ -206,38 +186,37 @@ typedef enum libcoopgamma_support
* of bits for integral types, and
* negative for floating-point types
*/
-typedef enum libcoopgamma_depth
-{
- /**
- * `uint8_t`
- */
- LIBCOOPGAMMA_UINT8 = 8,
-
- /**
- * `uint16_t`
- */
- LIBCOOPGAMMA_UINT16 = 16,
-
- /**
- * `uint32_t`
- */
- LIBCOOPGAMMA_UINT32 = 32,
-
- /**
- * `uint64_t`
- */
- LIBCOOPGAMMA_UINT64 = 64,
-
- /**
- * `float`
- */
- LIBCOOPGAMMA_FLOAT = -1,
-
- /**
- * `double`
- */
- LIBCOOPGAMMA_DOUBLE = -2
-
+typedef enum libcoopgamma_depth {
+ /**
+ * `uint8_t`
+ */
+ LIBCOOPGAMMA_UINT8 = 8,
+
+ /**
+ * `uint16_t`
+ */
+ LIBCOOPGAMMA_UINT16 = 16,
+
+ /**
+ * `uint32_t`
+ */
+ LIBCOOPGAMMA_UINT32 = 32,
+
+ /**
+ * `uint64_t`
+ */
+ LIBCOOPGAMMA_UINT64 = 64,
+
+ /**
+ * `float`
+ */
+ LIBCOOPGAMMA_FLOAT = -1,
+
+ /**
+ * `double`
+ */
+ LIBCOOPGAMMA_DOUBLE = -2
+
} libcoopgamma_depth_t;
@@ -245,63 +224,61 @@ typedef enum libcoopgamma_depth
* Values used to tell when a filter
* should be removed
*/
-typedef enum libcoopgamma_lifespan
-{
- /**
- * Remove the filter now
- *
- * This value will always be 0
- */
- LIBCOOPGAMMA_REMOVE = 0,
-
- /**
- * Remove the filter when disconnecting
- * from the coopgamma server
- */
- LIBCOOPGAMMA_UNTIL_DEATH = 1,
-
- /**
- * Only remove the filter when it
- * is explicitly requested
- */
- LIBCOOPGAMMA_UNTIL_REMOVAL = 2
-
+typedef enum libcoopgamma_lifespan {
+ /**
+ * Remove the filter now
+ *
+ * This value will always be 0
+ */
+ LIBCOOPGAMMA_REMOVE = 0,
+
+ /**
+ * Remove the filter when disconnecting
+ * from the coopgamma server
+ */
+ LIBCOOPGAMMA_UNTIL_DEATH = 1,
+
+ /**
+ * Only remove the filter when it
+ * is explicitly requested
+ */
+ LIBCOOPGAMMA_UNTIL_REMOVAL = 2
+
} libcoopgamma_lifespan_t;
/**
* Colourspaces
*/
-typedef enum libcoopgamma_colourspace
-{
- /**
- * The colourspace is unknown
- *
- * This value will always be 0
- */
- LIBCOOPGAMMA_UNKNOWN = 0,
-
- /**
- * sRGB (Standard RGB)
- */
- LIBCOOPGAMMA_SRGB = 1,
-
- /**
- * RGB other than sRGB
- */
- LIBCOOPGAMMA_RGB = 2,
-
- /**
- * Non-RGB multicolour
- */
- LIBCOOPGAMMA_NON_RGB = 3,
-
- /**
- * Monochrome, greyscale, or some
- * other singlecolour scale
- */
- LIBCOOPGAMMA_GREY = 4
-
+typedef enum libcoopgamma_colourspace {
+ /**
+ * The colourspace is unknown
+ *
+ * This value will always be 0
+ */
+ LIBCOOPGAMMA_UNKNOWN = 0,
+
+ /**
+ * sRGB (Standard RGB)
+ */
+ LIBCOOPGAMMA_SRGB = 1,
+
+ /**
+ * RGB other than sRGB
+ */
+ LIBCOOPGAMMA_RGB = 2,
+
+ /**
+ * Non-RGB multicolour
+ */
+ LIBCOOPGAMMA_NON_RGB = 3,
+
+ /**
+ * Monochrome, greyscale, or some
+ * other singlecolour scale
+ */
+ LIBCOOPGAMMA_GREY = 4
+
} libcoopgamma_colourspace_t;
@@ -311,39 +288,38 @@ typedef enum libcoopgamma_colourspace
* @param suffix:identifier The end of the name of the `struct`
* @param type:scalar-type The datatype of the stops
*/
-#define LIBCOOPGAMMA_RAMPS__(suffix, type) \
-typedef struct libcoopgamma_ramps##suffix \
-{ \
- /**
- * The number of stops in the red ramp
- */ \
- size_t red_size; \
- \
- /**
- * The number of stops in the green ramp
- */ \
- size_t green_size; \
- \
- /**
- * The number of stops in the blue ramp
- */ \
- size_t blue_size; \
- \
- /**
- * The red ramp
- */ \
- type* red; \
- \
- /**
- * The green ramp
- */ \
- type* green; \
- \
- /**
- * The blue ramp
- */ \
- type* blue; \
- \
+#define LIBCOOPGAMMA_RAMPS__(suffix, type)\
+typedef struct libcoopgamma_ramps##suffix {\
+ /**
+ * The number of stops in the red ramp
+ */\
+ size_t red_size;\
+ \
+ /**
+ * The number of stops in the green ramp
+ */\
+ size_t green_size;\
+ \
+ /**
+ * The number of stops in the blue ramp
+ */\
+ size_t blue_size;\
+ \
+ /**
+ * The red ramp
+ */\
+ type *red;\
+ \
+ /**
+ * The green ramp
+ */\
+ type *green;\
+ \
+ /**
+ * The blue ramp
+ */\
+ type *blue;\
+ \
} libcoopgamma_ramps##suffix##_t
/**
@@ -392,38 +368,37 @@ LIBCOOPGAMMA_RAMPS__(d, double);
/**
* Union with all ramp types.
*/
-typedef union libcoopgamma_ramps
-{
- /**
- * 8-bit version
- */
- libcoopgamma_ramps8_t u8;
-
- /**
- * 16-bit version
- */
- libcoopgamma_ramps16_t u16;
-
- /**
- * 32-bit version
- */
- libcoopgamma_ramps32_t u32;
-
- /**
- * 64-bit version
- */
- libcoopgamma_ramps64_t u64;
-
- /**
- * Single precision floating-point version
- */
- libcoopgamma_rampsf_t f;
-
- /**
- * Double precision floating-point version
- */
- libcoopgamma_rampsd_t d;
-
+typedef union libcoopgamma_ramps {
+ /**
+ * 8-bit version
+ */
+ libcoopgamma_ramps8_t u8;
+
+ /**
+ * 16-bit version
+ */
+ libcoopgamma_ramps16_t u16;
+
+ /**
+ * 32-bit version
+ */
+ libcoopgamma_ramps32_t u32;
+
+ /**
+ * 64-bit version
+ */
+ libcoopgamma_ramps64_t u64;
+
+ /**
+ * Single precision floating-point version
+ */
+ libcoopgamma_rampsf_t f;
+
+ /**
+ * Double precision floating-point version
+ */
+ libcoopgamma_rampsd_t d;
+
} libcoopgamma_ramps_t;
@@ -431,153 +406,151 @@ typedef union libcoopgamma_ramps
* Data set to the coopgamma server to apply,
* update, or remove a filter.
*/
-typedef struct libcoopgamma_filter
-{
- /**
- * The priority of the filter, higher priority
- * is applied first. The gamma correction should
- * have priority 0.
- */
- int64_t priority;
-
- /**
- * The CRTC for which this filter shall be applied
- */
- char* crtc;
-
- /**
- * Identifier for the filter
- *
- * The syntax must be "${PACKAGE_NAME}::${COMMAND_NAME}::${RULE}"
- */
- char* class;
-
- /**
- * When shall the filter be removed?
- *
- * If this member's value is `LIBCOOPGAMMA_REMOVE`,
- * only `.crtc` and `.class` need also be defined
- */
- libcoopgamma_lifespan_t lifespan;
-
- /**
- * The data type and bit-depth of the ramp stops
- */
- libcoopgamma_depth_t depth;
-
- /**
- * The gamma ramp adjustments of the filter
- */
- libcoopgamma_ramps_t ramps;
-
+typedef struct libcoopgamma_filter {
+ /**
+ * The priority of the filter, higher priority
+ * is applied first. The gamma correction should
+ * have priority 0.
+ */
+ int64_t priority;
+
+ /**
+ * The CRTC for which this filter shall be applied
+ */
+ char *crtc;
+
+ /**
+ * Identifier for the filter
+ *
+ * The syntax must be "${PACKAGE_NAME}::${COMMAND_NAME}::${RULE}"
+ */
+ char *class;
+
+ /**
+ * When shall the filter be removed?
+ *
+ * If this member's value is `LIBCOOPGAMMA_REMOVE`,
+ * only `.crtc` and `.class` need also be defined
+ */
+ libcoopgamma_lifespan_t lifespan;
+
+ /**
+ * The data type and bit-depth of the ramp stops
+ */
+ libcoopgamma_depth_t depth;
+
+ /**
+ * The gamma ramp adjustments of the filter
+ */
+ libcoopgamma_ramps_t ramps;
+
} libcoopgamma_filter_t;
/**
* Gamma ramp meta information for a CRTC
*/
-typedef struct libcoopgamma_crtc_info
-{
- /**
- * Is cooperative gamma server running?
- */
- int cooperative;
-
- /**
- * The data type and bit-depth of the ramp stops
- */
- libcoopgamma_depth_t depth;
-
- /**
- * Is gamma adjustments supported on the CRTC?
- * If not, `.depth`, `.red_size`, `.green_size`,
- * and `.blue_size` are undefined
- */
- libcoopgamma_support_t supported;
-
+typedef struct libcoopgamma_crtc_info {
+ /**
+ * Is cooperative gamma server running?
+ */
+ int cooperative;
+
+ /**
+ * The data type and bit-depth of the ramp stops
+ */
+ libcoopgamma_depth_t depth;
+
+ /**
+ * Is gamma adjustments supported on the CRTC?
+ * If not, `.depth`, `.red_size`, `.green_size`,
+ * and `.blue_size` are undefined
+ */
+ libcoopgamma_support_t supported;
+
#if INT_MAX != LONG_MAX
- int padding__;
+ int padding__;
#endif
-
- /**
- * The number of stops in the red ramp
- */
- size_t red_size;
-
- /**
- * The number of stops in the green ramp
- */
- size_t green_size;
-
- /**
- * The number of stops in the blue ramp
- */
- size_t blue_size;
-
- /**
- * The monitor's colourspace
- */
- libcoopgamma_colourspace_t colourspace;
-
- /**
- * Whether `.red_x`, `.red_y`, `.green_x`,
- * `.green_y`, `.blue_x`, `.blue_y`,
- * `.white_x`, and `.white_y` are set.
- *
- * If this is true, but the colourspace
- * is not RGB (or sRGB), there is something
- * wrong. Please also check the colourspace.
- */
- int have_gamut;
-
- /**
- * The x-value (CIE xyY) of the monitor's
- * red colour, multiplied by 1024
- */
- unsigned red_x;
-
- /**
- * The y-value (CIE xyY) of the monitor's
- * red colour, multiplied by 1024
- */
- unsigned red_y;
-
- /**
- * The x-value (CIE xyY) of the monitor's
- * green colour, multiplied by 1024
- */
- unsigned green_x;
-
- /**
- * The y-value (CIE xyY) of the monitor's
- * green colour, multiplied by 1024
- */
- unsigned green_y;
-
- /**
- * The x-value (CIE xyY) of the monitor's
- * blue colour, multiplied by 1024
- */
- unsigned blue_x;
-
- /**
- * The y-value (CIE xyY) of the monitor's
- * blue colour, multiplied by 1024
- */
- unsigned blue_y;
-
- /**
- * The x-value (CIE xyY) of the monitor's
- * default white point, multiplied by 1024
- */
- unsigned white_x;
-
- /**
- * The y-value (CIE xyY) of the monitor's
- * default white point, multiplied by 1024
- */
- unsigned white_y;
-
+
+ /**
+ * The number of stops in the red ramp
+ */
+ size_t red_size;
+
+ /**
+ * The number of stops in the green ramp
+ */
+ size_t green_size;
+
+ /**
+ * The number of stops in the blue ramp
+ */
+ size_t blue_size;
+
+ /**
+ * The monitor's colourspace
+ */
+ libcoopgamma_colourspace_t colourspace;
+
+ /**
+ * Whether `.red_x`, `.red_y`, `.green_x`,
+ * `.green_y`, `.blue_x`, `.blue_y`,
+ * `.white_x`, and `.white_y` are set.
+ *
+ * If this is true, but the colourspace
+ * is not RGB (or sRGB), there is something
+ * wrong. Please also check the colourspace.
+ */
+ int have_gamut;
+
+ /**
+ * The x-value (CIE xyY) of the monitor's
+ * red colour, multiplied by 1024
+ */
+ unsigned red_x;
+
+ /**
+ * The y-value (CIE xyY) of the monitor's
+ * red colour, multiplied by 1024
+ */
+ unsigned red_y;
+
+ /**
+ * The x-value (CIE xyY) of the monitor's
+ * green colour, multiplied by 1024
+ */
+ unsigned green_x;
+
+ /**
+ * The y-value (CIE xyY) of the monitor's
+ * green colour, multiplied by 1024
+ */
+ unsigned green_y;
+
+ /**
+ * The x-value (CIE xyY) of the monitor's
+ * blue colour, multiplied by 1024
+ */
+ unsigned blue_x;
+
+ /**
+ * The y-value (CIE xyY) of the monitor's
+ * blue colour, multiplied by 1024
+ */
+ unsigned blue_y;
+
+ /**
+ * The x-value (CIE xyY) of the monitor's
+ * default white point, multiplied by 1024
+ */
+ unsigned white_x;
+
+ /**
+ * The y-value (CIE xyY) of the monitor's
+ * default white point, multiplied by 1024
+ */
+ unsigned white_y;
+
} libcoopgamma_crtc_info_t;
@@ -586,36 +559,35 @@ typedef struct libcoopgamma_crtc_info
* when requestng the current filter
* table
*/
-typedef struct libcoopgamma_filter_query
-{
- /**
- * Do no return filters with higher
- * priority than this value
- */
- int64_t high_priority;
-
- /**
- * Do no return filters with lower
- * priority than this value
- */
- int64_t low_priority;
-
- /**
- * The CRTC for which the the current
- * filters shall returned
- */
- char* crtc;
-
- /**
- * Whether to coalesce all filters
- * into one gamma ramp triplet
- */
- int coalesce;
-
+typedef struct libcoopgamma_filter_query {
+ /**
+ * Do no return filters with higher
+ * priority than this value
+ */
+ int64_t high_priority;
+
+ /**
+ * Do no return filters with lower
+ * priority than this value
+ */
+ int64_t low_priority;
+
+ /**
+ * The CRTC for which the the current
+ * filters shall returned
+ */
+ char *crtc;
+
+ /**
+ * Whether to coalesce all filters
+ * into one gamma ramp triplet
+ */
+ int coalesce;
+
#if INT_MAX != LONG_MAX
- int padding__;
+ int padding__;
#endif
-
+
} libcoopgamma_filter_query_t;
@@ -624,23 +596,22 @@ typedef struct libcoopgamma_filter_query
* which only contains the information returned
* in response to "Command: get-gamma"
*/
-typedef struct libcoopgamma_queried_filter
-{
- /**
- * The filter's priority
- */
- int64_t priority;
-
- /**
- * The filter's class
- */
- char* class;
-
- /**
- * The gamma ramp adjustments of the filter
- */
- libcoopgamma_ramps_t ramps;
-
+typedef struct libcoopgamma_queried_filter {
+ /**
+ * The filter's priority
+ */
+ int64_t priority;
+
+ /**
+ * The filter's class
+ */
+ char *class;
+
+ /**
+ * The gamma ramp adjustments of the filter
+ */
+ libcoopgamma_ramps_t ramps;
+
} libcoopgamma_queried_filter_t;
@@ -649,82 +620,80 @@ typedef struct libcoopgamma_queried_filter
* list of applied filters and meta-information
* that was necessary for decoding the response
*/
-typedef struct libcoopgamma_filter_table
-{
- /**
- * The number of stops in the red ramp
- */
- size_t red_size;
-
- /**
- * The number of stops in the green ramp
- */
- size_t green_size;
-
- /**
- * The number of stops in the blue ramp
- */
- size_t blue_size;
-
- /**
- * The number of filters
- */
- size_t filter_count;
-
- /**
- * The filters, should be ordered by priority
- * in descending order, lest there is something
- * wrong with the coopgamma server
- *
- * If filter coalition was requested, there will
- * be exactly one filter (`.filter_count == 1`)
- * and `.filters->class == NULL` and
- * `.filters->priority` is undefined.
- */
- libcoopgamma_queried_filter_t* filters;
-
- /**
- * The data type and bit-depth of the ramp stops
- */
- libcoopgamma_depth_t depth;
-
+typedef struct libcoopgamma_filter_table {
+ /**
+ * The number of stops in the red ramp
+ */
+ size_t red_size;
+
+ /**
+ * The number of stops in the green ramp
+ */
+ size_t green_size;
+
+ /**
+ * The number of stops in the blue ramp
+ */
+ size_t blue_size;
+
+ /**
+ * The number of filters
+ */
+ size_t filter_count;
+
+ /**
+ * The filters, should be ordered by priority
+ * in descending order, lest there is something
+ * wrong with the coopgamma server
+ *
+ * If filter coalition was requested, there will
+ * be exactly one filter (`.filter_count == 1`)
+ * and `.filters->class == NULL` and
+ * `.filters->priority` is undefined.
+ */
+ libcoopgamma_queried_filter_t *filters;
+
+ /**
+ * The data type and bit-depth of the ramp stops
+ */
+ libcoopgamma_depth_t depth;
+
#if INT_MAX != LONG_MAX
- int padding__;
+ int padding__;
#endif
-
+
} libcoopgamma_filter_table_t;
/**
* Error message from coopgamma server
*/
-typedef struct libcoopgamma_error
-{
- /**
- * Error code
- *
- * If `.custom` is false, 0 indicates
- * success, otherwise, 0 indicates that
- * no error code has been assigned
- */
- uint64_t number;
-
- /**
- * Is this a custom error?
- */
- int custom;
-
- /**
- * Did the error occur on the server-side?
- */
- int server_side;
-
- /**
- * Error message, can be `NULL` if
- * `.custom` is false
- */
- char* description;
-
+typedef struct libcoopgamma_error {
+ /**
+ * Error code
+ *
+ * If `.custom` is false, 0 indicates
+ * success, otherwise, 0 indicates that
+ * no error code has been assigned
+ */
+ uint64_t number;
+
+ /**
+ * Is this a custom error?
+ */
+ int custom;
+
+ /**
+ * Did the error occur on the server-side?
+ */
+ int server_side;
+
+ /**
+ * Error message, can be `NULL` if
+ * `.custom` is false
+ */
+ char *description;
+
} libcoopgamma_error_t;
@@ -735,103 +704,102 @@ typedef struct libcoopgamma_error
* create one instance per thread that uses
* this structure
*/
-typedef struct libcoopgamma_context
-{
- /**
- * The error of the last failed function call
- *
- * This member is undefined after successful function call
- */
- libcoopgamma_error_t error;
-
- /**
- * File descriptor for the socket
- */
- int fd;
-
- /* The members below are internal. */
-
- /**
- * Whether `libcoopgamma_synchronise` have
- * read the empty end-of-headers line
- */
- int have_all_headers;
-
- /**
- * Whether `libcoopgamma_synchronise` is reading
- * a corrupt but recoverable message
- */
- int bad_message;
-
- /**
- * Is communication blocking?
- */
- int blocking;
-
- /**
- * Message ID of the next message
- */
- uint32_t message_id;
-
- /**
- * The ID of outbound message to which the inbound
- * message being read by `libcoopgamma_synchronise`
- * is a response
- */
- uint32_t in_response_to;
-
- /**
- * Buffer with the outbound message
- */
- char* outbound;
-
- /**
- * The write head for `outbound`
- */
- size_t outbound_head;
-
- /**
- * The read head for `outbound`
- */
- size_t outbound_tail;
-
- /**
- * The allocation size of `outbound`
- */
- size_t outbound_size;
-
- /**
- * Buffer with the inbound message
- */
- char* inbound;
-
- /**
- * The write head for `inbound`
- */
- size_t inbound_head;
-
- /**
- * The read head for `inbound`
- */
- size_t inbound_tail;
-
- /**
- * The allocation size of `inbound`
- */
- size_t inbound_size;
-
- /**
- * The value of 'Length' header in
- * the inbound message
- */
- size_t length;
-
- /**
- * The beginning of the current line that
- * is being read by `libcoopgamma_synchronise`
- */
- size_t curline;
-
+typedef struct libcoopgamma_context {
+ /**
+ * The error of the last failed function call
+ *
+ * This member is undefined after successful function call
+ */
+ libcoopgamma_error_t error;
+
+ /**
+ * File descriptor for the socket
+ */
+ int fd;
+
+ /* The members below are internal. */
+
+ /**
+ * Whether `libcoopgamma_synchronise` have
+ * read the empty end-of-headers line
+ */
+ int have_all_headers;
+
+ /**
+ * Whether `libcoopgamma_synchronise` is reading
+ * a corrupt but recoverable message
+ */
+ int bad_message;
+
+ /**
+ * Is communication blocking?
+ */
+ int blocking;
+
+ /**
+ * Message ID of the next message
+ */
+ uint32_t message_id;
+
+ /**
+ * The ID of outbound message to which the inbound
+ * message being read by `libcoopgamma_synchronise`
+ * is a response
+ */
+ uint32_t in_response_to;
+
+ /**
+ * Buffer with the outbound message
+ */
+ char *outbound;
+
+ /**
+ * The write head for `outbound`
+ */
+ size_t outbound_head;
+
+ /**
+ * The read head for `outbound`
+ */
+ size_t outbound_tail;
+
+ /**
+ * The allocation size of `outbound`
+ */
+ size_t outbound_size;
+
+ /**
+ * Buffer with the inbound message
+ */
+ char *inbound;
+
+ /**
+ * The write head for `inbound`
+ */
+ size_t inbound_head;
+
+ /**
+ * The read head for `inbound`
+ */
+ size_t inbound_tail;
+
+ /**
+ * The allocation size of `inbound`
+ */
+ size_t inbound_size;
+
+ /**
+ * The value of 'Length' header in
+ * the inbound message
+ */
+ size_t length;
+
+ /**
+ * The beginning of the current line that
+ * is being read by `libcoopgamma_synchronise`
+ */
+ size_t curline;
+
} libcoopgamma_context_t;
@@ -839,22 +807,21 @@ typedef struct libcoopgamma_context
* Information necessary to identify and
* parse a response from the server
*/
-typedef struct libcoopgamma_async_context
-{
- /* All members are internal. */
-
- /**
- * The value of the 'In response to' header
- * in the waited message
- */
- uint32_t message_id;
-
- /**
- * Whether to coalesce all filters
- * into one gamma ramp triplet
- */
- int coalesce;
-
+typedef struct libcoopgamma_async_context {
+ /* All members are internal. */
+
+ /**
+ * The value of the 'In response to' header
+ * in the waited message
+ */
+ uint32_t message_id;
+
+ /**
+ * Whether to coalesce all filters
+ * into one gamma ramp triplet
+ */
+ int coalesce;
+
} libcoopgamma_async_context_t;
@@ -868,8 +835,8 @@ typedef struct libcoopgamma_async_context
* @param this The record to initialise
* @return Zero on success, -1 on error
*/
-#define libcoopgamma_ramps_initialise(this) \
- (libcoopgamma_ramps_initialise_((this), sizeof(*((this)->red))))
+#define libcoopgamma_ramps_initialise(this)\
+ (libcoopgamma_ramps_initialise_((this), sizeof(*((this)->red))))
/**
* Marshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
@@ -881,8 +848,8 @@ typedef struct libcoopgamma_async_context
* @return The number of marshalled bytes, or if `buf == NULL`,
* how many bytes would be marshalled if `buf != NULL`
*/
-#define libcoopgamma_ramps_marshal(this, buf) \
- (libcoopgamma_ramps_marshal_((this), (buf), sizeof(*((this)->red))))
+#define libcoopgamma_ramps_marshal(this, buf)\
+ (libcoopgamma_ramps_marshal_((this), (buf), sizeof(*((this)->red))))
/**
* Unmarshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
@@ -894,8 +861,8 @@ typedef struct libcoopgamma_async_context
* @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
-#define libcoopgamma_ramps_unmarshal(this, buf, n) \
- (libcoopgamma_ramps_unmarshal_((this), (buf), (n), sizeof(*((this)->red))))
+#define libcoopgamma_ramps_unmarshal(this, buf, n)\
+ (libcoopgamma_ramps_unmarshal_((this), (buf), (n), sizeof(*((this)->red))))
/**
@@ -909,7 +876,7 @@ typedef struct libcoopgamma_async_context
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_ramps_initialise_(void* restrict, size_t);
+int libcoopgamma_ramps_initialise_(void *restrict, size_t);
/**
* Release all resources allocated to a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`,
@@ -923,7 +890,7 @@ int libcoopgamma_ramps_initialise_(void* restrict, size_t);
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-void libcoopgamma_ramps_destroy(void* restrict);
+void libcoopgamma_ramps_destroy(void *restrict);
/**
* Marshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
@@ -937,7 +904,7 @@ void libcoopgamma_ramps_destroy(void* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1), __leaf__)))
-size_t libcoopgamma_ramps_marshal_(const void* restrict, void* restrict, size_t);
+size_t libcoopgamma_ramps_marshal_(const void *restrict, void *restrict, size_t);
/**
* Unmarshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
@@ -951,7 +918,7 @@ size_t libcoopgamma_ramps_marshal_(const void* restrict, void* restrict, size_t)
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_ramps_unmarshal_(void* restrict, const void* restrict, size_t* restrict, size_t);
+int libcoopgamma_ramps_unmarshal_(void *restrict, const void *restrict, size_t *restrict, size_t);
/**
@@ -961,7 +928,7 @@ int libcoopgamma_ramps_unmarshal_(void* restrict, const void* restrict, size_t*
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_filter_initialise(libcoopgamma_filter_t* restrict);
+int libcoopgamma_filter_initialise(libcoopgamma_filter_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_filter_t`,
@@ -973,7 +940,7 @@ int libcoopgamma_filter_initialise(libcoopgamma_filter_t* restrict);
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-void libcoopgamma_filter_destroy(libcoopgamma_filter_t* restrict);
+void libcoopgamma_filter_destroy(libcoopgamma_filter_t *restrict);
/**
* Marshal a `libcoopgamma_filter_t` into a buffer
@@ -985,7 +952,7 @@ void libcoopgamma_filter_destroy(libcoopgamma_filter_t* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1))))
-size_t libcoopgamma_filter_marshal(const libcoopgamma_filter_t* restrict, void* restrict);
+size_t libcoopgamma_filter_marshal(const libcoopgamma_filter_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_filter_t` from a buffer
@@ -997,7 +964,7 @@ size_t libcoopgamma_filter_marshal(const libcoopgamma_filter_t* restrict, void*
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_filter_unmarshal(libcoopgamma_filter_t* restrict, const void* restrict, size_t* restrict);
+int libcoopgamma_filter_unmarshal(libcoopgamma_filter_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1007,7 +974,7 @@ int libcoopgamma_filter_unmarshal(libcoopgamma_filter_t* restrict, const void* r
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_crtc_info_initialise(libcoopgamma_crtc_info_t* restrict);
+int libcoopgamma_crtc_info_initialise(libcoopgamma_crtc_info_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_crtc_info_t`,
@@ -1019,7 +986,7 @@ int libcoopgamma_crtc_info_initialise(libcoopgamma_crtc_info_t* restrict);
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-void libcoopgamma_crtc_info_destroy(libcoopgamma_crtc_info_t* restrict);
+void libcoopgamma_crtc_info_destroy(libcoopgamma_crtc_info_t *restrict);
/**
* Marshal a `libcoopgamma_crtc_info_t` into a buffer
@@ -1031,7 +998,7 @@ void libcoopgamma_crtc_info_destroy(libcoopgamma_crtc_info_t* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1), __leaf__)))
-size_t libcoopgamma_crtc_info_marshal(const libcoopgamma_crtc_info_t* restrict, void* restrict);
+size_t libcoopgamma_crtc_info_marshal(const libcoopgamma_crtc_info_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_crtc_info_t` from a buffer
@@ -1043,8 +1010,7 @@ size_t libcoopgamma_crtc_info_marshal(const libcoopgamma_crtc_info_t* restrict,
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_crtc_info_unmarshal(libcoopgamma_crtc_info_t* restrict,
- const void* restrict, size_t* restrict);
+int libcoopgamma_crtc_info_unmarshal(libcoopgamma_crtc_info_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1054,7 +1020,7 @@ int libcoopgamma_crtc_info_unmarshal(libcoopgamma_crtc_info_t* restrict,
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_filter_query_initialise(libcoopgamma_filter_query_t* restrict);
+int libcoopgamma_filter_query_initialise(libcoopgamma_filter_query_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_filter_query_t`,
@@ -1066,7 +1032,7 @@ int libcoopgamma_filter_query_initialise(libcoopgamma_filter_query_t* restrict);
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-void libcoopgamma_filter_query_destroy(libcoopgamma_filter_query_t* restrict);
+void libcoopgamma_filter_query_destroy(libcoopgamma_filter_query_t *restrict);
/**
* Marshal a `libcoopgamma_filter_query_t` into a buffer
@@ -1078,7 +1044,7 @@ void libcoopgamma_filter_query_destroy(libcoopgamma_filter_query_t* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1), __leaf__)))
-size_t libcoopgamma_filter_query_marshal(const libcoopgamma_filter_query_t* restrict, void* restrict);
+size_t libcoopgamma_filter_query_marshal(const libcoopgamma_filter_query_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_filter_query_t` from a buffer
@@ -1090,8 +1056,7 @@ size_t libcoopgamma_filter_query_marshal(const libcoopgamma_filter_query_t* rest
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_filter_query_unmarshal(libcoopgamma_filter_query_t* restrict,
- const void* restrict, size_t* restrict);
+int libcoopgamma_filter_query_unmarshal(libcoopgamma_filter_query_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1101,7 +1066,7 @@ int libcoopgamma_filter_query_unmarshal(libcoopgamma_filter_query_t* restrict,
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_queried_filter_initialise(libcoopgamma_queried_filter_t* restrict);
+int libcoopgamma_queried_filter_initialise(libcoopgamma_queried_filter_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_queried_filter_t`,
@@ -1113,7 +1078,7 @@ int libcoopgamma_queried_filter_initialise(libcoopgamma_queried_filter_t* restri
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-void libcoopgamma_queried_filter_destroy(libcoopgamma_queried_filter_t* restrict);
+void libcoopgamma_queried_filter_destroy(libcoopgamma_queried_filter_t *restrict);
/**
* Marshal a `libcoopgamma_queried_filter_t` into a buffer
@@ -1126,8 +1091,7 @@ void libcoopgamma_queried_filter_destroy(libcoopgamma_queried_filter_t* restrict
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1))))
-size_t libcoopgamma_queried_filter_marshal(const libcoopgamma_queried_filter_t* restrict, void* restrict,
- libcoopgamma_depth_t);
+size_t libcoopgamma_queried_filter_marshal(const libcoopgamma_queried_filter_t *restrict, void *restrict, libcoopgamma_depth_t);
/**
* Unmarshal a `libcoopgamma_queried_filter_t` from a buffer
@@ -1140,8 +1104,8 @@ size_t libcoopgamma_queried_filter_marshal(const libcoopgamma_queried_filter_t*
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_queried_filter_unmarshal(libcoopgamma_queried_filter_t* restrict,
- const void* restrict, size_t* restrict, libcoopgamma_depth_t);
+int libcoopgamma_queried_filter_unmarshal(libcoopgamma_queried_filter_t *restrict, const void *restrict,
+ size_t *restrict, libcoopgamma_depth_t);
/**
@@ -1151,7 +1115,7 @@ int libcoopgamma_queried_filter_unmarshal(libcoopgamma_queried_filter_t* restric
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_filter_table_initialise(libcoopgamma_filter_table_t* restrict);
+int libcoopgamma_filter_table_initialise(libcoopgamma_filter_table_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_filter_table_t`,
@@ -1163,7 +1127,7 @@ int libcoopgamma_filter_table_initialise(libcoopgamma_filter_table_t* restrict);
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-void libcoopgamma_filter_table_destroy(libcoopgamma_filter_table_t* restrict);
+void libcoopgamma_filter_table_destroy(libcoopgamma_filter_table_t *restrict);
/**
* Marshal a `libcoopgamma_filter_table_t` into a buffer
@@ -1175,7 +1139,7 @@ void libcoopgamma_filter_table_destroy(libcoopgamma_filter_table_t* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1))))
-size_t libcoopgamma_filter_table_marshal(const libcoopgamma_filter_table_t* restrict, void* restrict);
+size_t libcoopgamma_filter_table_marshal(const libcoopgamma_filter_table_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_filter_table_t` from a buffer
@@ -1187,8 +1151,7 @@ size_t libcoopgamma_filter_table_marshal(const libcoopgamma_filter_table_t* rest
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_filter_table_unmarshal(libcoopgamma_filter_table_t* restrict,
- const void* restrict, size_t* restrict);
+int libcoopgamma_filter_table_unmarshal(libcoopgamma_filter_table_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1198,7 +1161,7 @@ int libcoopgamma_filter_table_unmarshal(libcoopgamma_filter_table_t* restrict,
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_error_initialise(libcoopgamma_error_t* restrict);
+int libcoopgamma_error_initialise(libcoopgamma_error_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_error_t`,
@@ -1210,7 +1173,7 @@ int libcoopgamma_error_initialise(libcoopgamma_error_t* restrict);
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-void libcoopgamma_error_destroy(libcoopgamma_error_t* restrict);
+void libcoopgamma_error_destroy(libcoopgamma_error_t *restrict);
/**
* Marshal a `libcoopgamma_error_t` into a buffer
@@ -1222,7 +1185,7 @@ void libcoopgamma_error_destroy(libcoopgamma_error_t* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1), __leaf__)))
-size_t libcoopgamma_error_marshal(const libcoopgamma_error_t* restrict, void* restrict);
+size_t libcoopgamma_error_marshal(const libcoopgamma_error_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_error_t` from a buffer
@@ -1234,7 +1197,7 @@ size_t libcoopgamma_error_marshal(const libcoopgamma_error_t* restrict, void* re
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_error_unmarshal(libcoopgamma_error_t* restrict, const void* restrict, size_t* restrict);
+int libcoopgamma_error_unmarshal(libcoopgamma_error_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1244,7 +1207,7 @@ int libcoopgamma_error_unmarshal(libcoopgamma_error_t* restrict, const void* res
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_context_initialise(libcoopgamma_context_t* restrict);
+int libcoopgamma_context_initialise(libcoopgamma_context_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_context_t`,
@@ -1257,7 +1220,7 @@ int libcoopgamma_context_initialise(libcoopgamma_context_t* restrict);
* @param disconnect Disconnect from the server?
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-void libcoopgamma_context_destroy(libcoopgamma_context_t* restrict, int);
+void libcoopgamma_context_destroy(libcoopgamma_context_t *restrict, int);
/**
* Marshal a `libcoopgamma_context_t` into a buffer
@@ -1269,7 +1232,7 @@ void libcoopgamma_context_destroy(libcoopgamma_context_t* restrict, int);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1))))
-size_t libcoopgamma_context_marshal(const libcoopgamma_context_t* restrict, void* restrict);
+size_t libcoopgamma_context_marshal(const libcoopgamma_context_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_context_t` from a buffer
@@ -1281,7 +1244,7 @@ size_t libcoopgamma_context_marshal(const libcoopgamma_context_t* restrict, void
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_context_unmarshal(libcoopgamma_context_t* restrict, const void* restrict, size_t* restrict);
+int libcoopgamma_context_unmarshal(libcoopgamma_context_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1291,7 +1254,7 @@ int libcoopgamma_context_unmarshal(libcoopgamma_context_t* restrict, const void*
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_async_context_initialise(libcoopgamma_async_context_t* restrict);
+int libcoopgamma_async_context_initialise(libcoopgamma_async_context_t *restrict);
/**
* Release all resources allocated to a `libcoopgamma_async_context_t`,
@@ -1303,7 +1266,7 @@ int libcoopgamma_async_context_initialise(libcoopgamma_async_context_t* restrict
* @param this The record to destroy
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-void libcoopgamma_async_context_destroy(libcoopgamma_async_context_t* restrict);
+void libcoopgamma_async_context_destroy(libcoopgamma_async_context_t *restrict);
/**
* Marshal a `libcoopgamma_async_context_t` into a buffer
@@ -1315,7 +1278,7 @@ void libcoopgamma_async_context_destroy(libcoopgamma_async_context_t* restrict);
* how many bytes would be marshalled if `buf != NULL`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1), __leaf__)))
-size_t libcoopgamma_async_context_marshal(const libcoopgamma_async_context_t* restrict, void* restrict);
+size_t libcoopgamma_async_context_marshal(const libcoopgamma_async_context_t *restrict, void *restrict);
/**
* Unmarshal a `libcoopgamma_async_context_t` from a buffer
@@ -1327,8 +1290,7 @@ size_t libcoopgamma_async_context_marshal(const libcoopgamma_async_context_t* re
* `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_async_context_unmarshal(libcoopgamma_async_context_t* restrict, const void* restrict,
- size_t* restrict);
+int libcoopgamma_async_context_unmarshal(libcoopgamma_async_context_t *restrict, const void *restrict, size_t *restrict);
/**
@@ -1341,7 +1303,7 @@ int libcoopgamma_async_context_unmarshal(libcoopgamma_async_context_t* restrict,
* outer pointer and cannot be freed. `NULL` on error.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__malloc__)))
-char** libcoopgamma_get_methods(void);
+char **libcoopgamma_get_methods(void);
/**
* Get the adjustment method and site
@@ -1360,8 +1322,7 @@ char** libcoopgamma_get_methods(void);
* with this parameter set to `NULL`.
* @return Zero on success, -1 on error
*/
-int libcoopgamma_get_method_and_site(const char* restrict, const char* restrict,
- char** restrict, char** restrict);
+int libcoopgamma_get_method_and_site(const char *restrict, const char *restrict, char **restrict, char **restrict);
/**
* Get the PID file of the coopgamma server
@@ -1375,7 +1336,7 @@ int libcoopgamma_get_method_and_site(const char* restrict, const char* restrict,
* case is detected by checking that `errno` is set to 0.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__malloc__)))
-char* libcoopgamma_get_pid_file(const char* restrict, const char* restrict);
+char *libcoopgamma_get_pid_file(const char *restrict, const char *restrict);
/**
* Get the socket file of the coopgamma server
@@ -1391,7 +1352,7 @@ char* libcoopgamma_get_pid_file(const char* restrict, const char* restrict);
* multi-server display server like mds.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__malloc__)))
-char* libcoopgamma_get_socket_file(const char* restrict, const char* restrict);
+char *libcoopgamma_get_socket_file(const char *restrict, const char *restrict);
/**
@@ -1408,7 +1369,7 @@ char* libcoopgamma_get_socket_file(const char* restrict, const char* restrict);
* to 0 if the server could not be initialised.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(3))))
-int libcoopgamma_connect(const char* restrict, const char* restrict, libcoopgamma_context_t* restrict);
+int libcoopgamma_connect(const char *restrict, const char *restrict, libcoopgamma_context_t *restrict);
/**
* By default communication is blocking, this function
@@ -1426,7 +1387,7 @@ int libcoopgamma_connect(const char* restrict, const char* restrict, libcoopgamm
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_set_nonblocking(libcoopgamma_context_t* restrict, int);
+int libcoopgamma_set_nonblocking(libcoopgamma_context_t *restrict, int);
/**
* Send all pending outbound data
@@ -1441,7 +1402,7 @@ int libcoopgamma_set_nonblocking(libcoopgamma_context_t* restrict, int);
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__, __leaf__)))
-int libcoopgamma_flush(libcoopgamma_context_t* restrict);
+int libcoopgamma_flush(libcoopgamma_context_t *restrict);
/**
* Wait for the next message to be received
@@ -1463,8 +1424,7 @@ int libcoopgamma_flush(libcoopgamma_context_t* restrict);
* beyond recover.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1, 4), __leaf__)))
-int libcoopgamma_synchronise(libcoopgamma_context_t* restrict, libcoopgamma_async_context_t* restrict,
- size_t, size_t* restrict);
+int libcoopgamma_synchronise(libcoopgamma_context_t *restrict, libcoopgamma_async_context_t *restrict, size_t, size_t *restrict);
/**
* Tell the library that you will not be parsing a receive message
@@ -1472,7 +1432,7 @@ int libcoopgamma_synchronise(libcoopgamma_context_t* restrict, libcoopgamma_asyn
* @param ctx The state of the library, must be connected
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-void libcoopgamma_skip_message(libcoopgamma_context_t* restrict);
+void libcoopgamma_skip_message(libcoopgamma_context_t *restrict);
/**
@@ -1486,7 +1446,7 @@ void libcoopgamma_skip_message(libcoopgamma_context_t* restrict);
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_crtcs_send(libcoopgamma_context_t* restrict, libcoopgamma_async_context_t* restrict);
+int libcoopgamma_get_crtcs_send(libcoopgamma_context_t *restrict, libcoopgamma_async_context_t *restrict);
/**
* List all available CRTC:s, receive response part
@@ -1500,7 +1460,7 @@ int libcoopgamma_get_crtcs_send(libcoopgamma_context_t* restrict, libcoopgamma_a
* for information about the error.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__malloc__, __nonnull__)))
-char** libcoopgamma_get_crtcs_recv(libcoopgamma_context_t* restrict, libcoopgamma_async_context_t* restrict);
+char **libcoopgamma_get_crtcs_recv(libcoopgamma_context_t *restrict, libcoopgamma_async_context_t *restrict);
/**
* List all available CRTC:s, synchronous version
@@ -1520,7 +1480,7 @@ char** libcoopgamma_get_crtcs_recv(libcoopgamma_context_t* restrict, libcoopgamm
* for information about the error.
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__malloc__, __nonnull__)))
-char** libcoopgamma_get_crtcs_sync(libcoopgamma_context_t* restrict);
+char **libcoopgamma_get_crtcs_sync(libcoopgamma_context_t *restrict);
/**
@@ -1535,8 +1495,7 @@ char** libcoopgamma_get_crtcs_sync(libcoopgamma_context_t* restrict);
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_gamma_info_send(const char* restrict, libcoopgamma_context_t* restrict,
- libcoopgamma_async_context_t* restrict);
+int libcoopgamma_get_gamma_info_send(const char *restrict, libcoopgamma_context_t *restrict, libcoopgamma_async_context_t *restrict);
/**
* Retrieve information about a CRTC:s gamma ramps, receive response part
@@ -1548,8 +1507,8 @@ int libcoopgamma_get_gamma_info_send(const char* restrict, libcoopgamma_context_
* (rather than `errno`) is read for information about the error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_gamma_info_recv(libcoopgamma_crtc_info_t* restrict, libcoopgamma_context_t* restrict,
- libcoopgamma_async_context_t* restrict);
+int libcoopgamma_get_gamma_info_recv(libcoopgamma_crtc_info_t *restrict, libcoopgamma_context_t *restrict,
+ libcoopgamma_async_context_t *restrict);
/**
* Retrieve information about a CRTC:s gamma ramps, synchronous version
@@ -1568,8 +1527,7 @@ int libcoopgamma_get_gamma_info_recv(libcoopgamma_crtc_info_t* restrict, libcoop
* (rather than `errno`) is read for information about the error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_gamma_info_sync(const char* restrict, libcoopgamma_crtc_info_t* restrict,
- libcoopgamma_context_t* restrict);
+int libcoopgamma_get_gamma_info_sync(const char *restrict, libcoopgamma_crtc_info_t *restrict, libcoopgamma_context_t *restrict);
/**
@@ -1584,8 +1542,8 @@ int libcoopgamma_get_gamma_info_sync(const char* restrict, libcoopgamma_crtc_inf
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_gamma_send(const libcoopgamma_filter_query_t* restrict, libcoopgamma_context_t* restrict,
- libcoopgamma_async_context_t* restrict);
+int libcoopgamma_get_gamma_send(const libcoopgamma_filter_query_t *restrict, libcoopgamma_context_t *restrict,
+ libcoopgamma_async_context_t *restrict);
/**
* Retrieve the current gamma ramp adjustments, receive response part
@@ -1597,8 +1555,8 @@ int libcoopgamma_get_gamma_send(const libcoopgamma_filter_query_t* restrict, lib
* (rather than `errno`) is read for information about the error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_gamma_recv(libcoopgamma_filter_table_t* restrict, libcoopgamma_context_t* restrict,
- libcoopgamma_async_context_t* restrict);
+int libcoopgamma_get_gamma_recv(libcoopgamma_filter_table_t *restrict, libcoopgamma_context_t *restrict,
+ libcoopgamma_async_context_t *restrict);
/**
* Retrieve the current gamma ramp adjustments, synchronous version
@@ -1617,9 +1575,9 @@ int libcoopgamma_get_gamma_recv(libcoopgamma_filter_table_t* restrict, libcoopga
* (rather than `errno`) is read for information about the error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_get_gamma_sync(const libcoopgamma_filter_query_t* restrict,
- libcoopgamma_filter_table_t* restrict,
- libcoopgamma_context_t* restrict);
+int libcoopgamma_get_gamma_sync(const libcoopgamma_filter_query_t *restrict,
+ libcoopgamma_filter_table_t *restrict,
+ libcoopgamma_context_t *restrict);
/**
@@ -1634,8 +1592,8 @@ int libcoopgamma_get_gamma_sync(const libcoopgamma_filter_query_t* restrict,
* @return Zero on success, -1 on error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_set_gamma_send(const libcoopgamma_filter_t* restrict,
- libcoopgamma_context_t* restrict, libcoopgamma_async_context_t* restrict);
+int libcoopgamma_set_gamma_send(const libcoopgamma_filter_t *restrict, libcoopgamma_context_t *restrict,
+ libcoopgamma_async_context_t *restrict);
/**
* Apply, update, or remove a gamma ramp adjustment, receive response part
@@ -1646,7 +1604,7 @@ int libcoopgamma_set_gamma_send(const libcoopgamma_filter_t* restrict,
* (rather than `errno`) is read for information about the error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_set_gamma_recv(libcoopgamma_context_t* restrict, libcoopgamma_async_context_t* restrict);
+int libcoopgamma_set_gamma_recv(libcoopgamma_context_t *restrict, libcoopgamma_async_context_t *restrict);
/**
* Apply, update, or remove a gamma ramp adjustment, synchronous version
@@ -1664,7 +1622,7 @@ int libcoopgamma_set_gamma_recv(libcoopgamma_context_t* restrict, libcoopgamma_a
* (rather than `errno`) is read for information about the error
*/
LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__)))
-int libcoopgamma_set_gamma_sync(const libcoopgamma_filter_t* restrict, libcoopgamma_context_t* restrict);
+int libcoopgamma_set_gamma_sync(const libcoopgamma_filter_t *restrict, libcoopgamma_context_t *restrict);
@@ -1674,7 +1632,4 @@ int libcoopgamma_set_gamma_sync(const libcoopgamma_filter_t* restrict, libcoopga
#undef LIBCOOPGAMMA_GCC_ONLY
-
-
#endif
-
diff --git a/doc/man/libcoopgamma.h.0 b/libcoopgamma.h.0
index 73a0b8a..73a0b8a 100644
--- a/doc/man/libcoopgamma.h.0
+++ b/libcoopgamma.h.0
diff --git a/doc/man/libcoopgamma_async_context_destroy.3 b/libcoopgamma_async_context_destroy.3
index 154ad77..154ad77 100644
--- a/doc/man/libcoopgamma_async_context_destroy.3
+++ b/libcoopgamma_async_context_destroy.3
diff --git a/doc/man/libcoopgamma_async_context_initialise.3 b/libcoopgamma_async_context_initialise.3
index 24cf859..24cf859 100644
--- a/doc/man/libcoopgamma_async_context_initialise.3
+++ b/libcoopgamma_async_context_initialise.3
diff --git a/doc/man/libcoopgamma_async_context_marshal.3 b/libcoopgamma_async_context_marshal.3
index e7197b8..e7197b8 100644
--- a/doc/man/libcoopgamma_async_context_marshal.3
+++ b/libcoopgamma_async_context_marshal.3
diff --git a/doc/man/libcoopgamma_async_context_unmarshal.3 b/libcoopgamma_async_context_unmarshal.3
index 5930980..5930980 100644
--- a/doc/man/libcoopgamma_async_context_unmarshal.3
+++ b/libcoopgamma_async_context_unmarshal.3
diff --git a/doc/man/libcoopgamma_connect.3 b/libcoopgamma_connect.3
index 594d43f..594d43f 100644
--- a/doc/man/libcoopgamma_connect.3
+++ b/libcoopgamma_connect.3
diff --git a/doc/man/libcoopgamma_context_destroy.3 b/libcoopgamma_context_destroy.3
index 0d144a8..0d144a8 100644
--- a/doc/man/libcoopgamma_context_destroy.3
+++ b/libcoopgamma_context_destroy.3
diff --git a/doc/man/libcoopgamma_context_initialise.3 b/libcoopgamma_context_initialise.3
index 367c0a9..367c0a9 100644
--- a/doc/man/libcoopgamma_context_initialise.3
+++ b/libcoopgamma_context_initialise.3
diff --git a/doc/man/libcoopgamma_context_marshal.3 b/libcoopgamma_context_marshal.3
index aa7feea..aa7feea 100644
--- a/doc/man/libcoopgamma_context_marshal.3
+++ b/libcoopgamma_context_marshal.3
diff --git a/doc/man/libcoopgamma_context_unmarshal.3 b/libcoopgamma_context_unmarshal.3
index f805163..f805163 100644
--- a/doc/man/libcoopgamma_context_unmarshal.3
+++ b/libcoopgamma_context_unmarshal.3
diff --git a/doc/man/libcoopgamma_crtc_info_destroy.3 b/libcoopgamma_crtc_info_destroy.3
index c67e81c..c67e81c 100644
--- a/doc/man/libcoopgamma_crtc_info_destroy.3
+++ b/libcoopgamma_crtc_info_destroy.3
diff --git a/doc/man/libcoopgamma_crtc_info_initialise.3 b/libcoopgamma_crtc_info_initialise.3
index 84f167d..84f167d 100644
--- a/doc/man/libcoopgamma_crtc_info_initialise.3
+++ b/libcoopgamma_crtc_info_initialise.3
diff --git a/doc/man/libcoopgamma_crtc_info_marshal.3 b/libcoopgamma_crtc_info_marshal.3
index 2a8b294..2a8b294 100644
--- a/doc/man/libcoopgamma_crtc_info_marshal.3
+++ b/libcoopgamma_crtc_info_marshal.3
diff --git a/doc/man/libcoopgamma_crtc_info_unmarshal.3 b/libcoopgamma_crtc_info_unmarshal.3
index 964b3b0..964b3b0 100644
--- a/doc/man/libcoopgamma_crtc_info_unmarshal.3
+++ b/libcoopgamma_crtc_info_unmarshal.3
diff --git a/doc/man/libcoopgamma_error_destroy.3 b/libcoopgamma_error_destroy.3
index 978d0ad..978d0ad 100644
--- a/doc/man/libcoopgamma_error_destroy.3
+++ b/libcoopgamma_error_destroy.3
diff --git a/doc/man/libcoopgamma_error_initialise.3 b/libcoopgamma_error_initialise.3
index fba20cf..fba20cf 100644
--- a/doc/man/libcoopgamma_error_initialise.3
+++ b/libcoopgamma_error_initialise.3
diff --git a/doc/man/libcoopgamma_error_marshal.3 b/libcoopgamma_error_marshal.3
index f168a1c..f168a1c 100644
--- a/doc/man/libcoopgamma_error_marshal.3
+++ b/libcoopgamma_error_marshal.3
diff --git a/doc/man/libcoopgamma_error_unmarshal.3 b/libcoopgamma_error_unmarshal.3
index b780cb2..b780cb2 100644
--- a/doc/man/libcoopgamma_error_unmarshal.3
+++ b/libcoopgamma_error_unmarshal.3
diff --git a/doc/man/libcoopgamma_filter_destroy.3 b/libcoopgamma_filter_destroy.3
index e246da3..e246da3 100644
--- a/doc/man/libcoopgamma_filter_destroy.3
+++ b/libcoopgamma_filter_destroy.3
diff --git a/doc/man/libcoopgamma_filter_initialise.3 b/libcoopgamma_filter_initialise.3
index d2889b4..d2889b4 100644
--- a/doc/man/libcoopgamma_filter_initialise.3
+++ b/libcoopgamma_filter_initialise.3
diff --git a/doc/man/libcoopgamma_filter_marshal.3 b/libcoopgamma_filter_marshal.3
index 982802d..982802d 100644
--- a/doc/man/libcoopgamma_filter_marshal.3
+++ b/libcoopgamma_filter_marshal.3
diff --git a/doc/man/libcoopgamma_filter_query_destroy.3 b/libcoopgamma_filter_query_destroy.3
index 83e5561..83e5561 100644
--- a/doc/man/libcoopgamma_filter_query_destroy.3
+++ b/libcoopgamma_filter_query_destroy.3
diff --git a/doc/man/libcoopgamma_filter_query_initialise.3 b/libcoopgamma_filter_query_initialise.3
index e2a8903..e2a8903 100644
--- a/doc/man/libcoopgamma_filter_query_initialise.3
+++ b/libcoopgamma_filter_query_initialise.3
diff --git a/doc/man/libcoopgamma_filter_query_marshal.3 b/libcoopgamma_filter_query_marshal.3
index 83d560d..83d560d 100644
--- a/doc/man/libcoopgamma_filter_query_marshal.3
+++ b/libcoopgamma_filter_query_marshal.3
diff --git a/doc/man/libcoopgamma_filter_query_unmarshal.3 b/libcoopgamma_filter_query_unmarshal.3
index 8adc09a..8adc09a 100644
--- a/doc/man/libcoopgamma_filter_query_unmarshal.3
+++ b/libcoopgamma_filter_query_unmarshal.3
diff --git a/doc/man/libcoopgamma_filter_table_destroy.3 b/libcoopgamma_filter_table_destroy.3
index 9fa4d61..9fa4d61 100644
--- a/doc/man/libcoopgamma_filter_table_destroy.3
+++ b/libcoopgamma_filter_table_destroy.3
diff --git a/doc/man/libcoopgamma_filter_table_initialise.3 b/libcoopgamma_filter_table_initialise.3
index 79ee8cf..79ee8cf 100644
--- a/doc/man/libcoopgamma_filter_table_initialise.3
+++ b/libcoopgamma_filter_table_initialise.3
diff --git a/doc/man/libcoopgamma_filter_table_marshal.3 b/libcoopgamma_filter_table_marshal.3
index bc17c8a..bc17c8a 100644
--- a/doc/man/libcoopgamma_filter_table_marshal.3
+++ b/libcoopgamma_filter_table_marshal.3
diff --git a/doc/man/libcoopgamma_filter_table_unmarshal.3 b/libcoopgamma_filter_table_unmarshal.3
index 3dd5cd2..3dd5cd2 100644
--- a/doc/man/libcoopgamma_filter_table_unmarshal.3
+++ b/libcoopgamma_filter_table_unmarshal.3
diff --git a/doc/man/libcoopgamma_filter_unmarshal.3 b/libcoopgamma_filter_unmarshal.3
index d9f1ee8..d9f1ee8 100644
--- a/doc/man/libcoopgamma_filter_unmarshal.3
+++ b/libcoopgamma_filter_unmarshal.3
diff --git a/doc/man/libcoopgamma_flush.3 b/libcoopgamma_flush.3
index 8ffaae2..8ffaae2 100644
--- a/doc/man/libcoopgamma_flush.3
+++ b/libcoopgamma_flush.3
diff --git a/doc/man/libcoopgamma_get_crtcs_recv.3 b/libcoopgamma_get_crtcs_recv.3
index 02f8daa..02f8daa 100644
--- a/doc/man/libcoopgamma_get_crtcs_recv.3
+++ b/libcoopgamma_get_crtcs_recv.3
diff --git a/doc/man/libcoopgamma_get_crtcs_send.3 b/libcoopgamma_get_crtcs_send.3
index 6afeed0..6afeed0 100644
--- a/doc/man/libcoopgamma_get_crtcs_send.3
+++ b/libcoopgamma_get_crtcs_send.3
diff --git a/doc/man/libcoopgamma_get_crtcs_sync.3 b/libcoopgamma_get_crtcs_sync.3
index 3a3eebf..3a3eebf 100644
--- a/doc/man/libcoopgamma_get_crtcs_sync.3
+++ b/libcoopgamma_get_crtcs_sync.3
diff --git a/doc/man/libcoopgamma_get_gamma_info_recv.3 b/libcoopgamma_get_gamma_info_recv.3
index 1307fe5..1307fe5 100644
--- a/doc/man/libcoopgamma_get_gamma_info_recv.3
+++ b/libcoopgamma_get_gamma_info_recv.3
diff --git a/doc/man/libcoopgamma_get_gamma_info_send.3 b/libcoopgamma_get_gamma_info_send.3
index 16a312d..16a312d 100644
--- a/doc/man/libcoopgamma_get_gamma_info_send.3
+++ b/libcoopgamma_get_gamma_info_send.3
diff --git a/doc/man/libcoopgamma_get_gamma_info_sync.3 b/libcoopgamma_get_gamma_info_sync.3
index 3187231..3187231 100644
--- a/doc/man/libcoopgamma_get_gamma_info_sync.3
+++ b/libcoopgamma_get_gamma_info_sync.3
diff --git a/doc/man/libcoopgamma_get_gamma_recv.3 b/libcoopgamma_get_gamma_recv.3
index 5697a86..5697a86 100644
--- a/doc/man/libcoopgamma_get_gamma_recv.3
+++ b/libcoopgamma_get_gamma_recv.3
diff --git a/doc/man/libcoopgamma_get_gamma_send.3 b/libcoopgamma_get_gamma_send.3
index ee202da..ee202da 100644
--- a/doc/man/libcoopgamma_get_gamma_send.3
+++ b/libcoopgamma_get_gamma_send.3
diff --git a/doc/man/libcoopgamma_get_gamma_sync.3 b/libcoopgamma_get_gamma_sync.3
index e46cecf..e46cecf 100644
--- a/doc/man/libcoopgamma_get_gamma_sync.3
+++ b/libcoopgamma_get_gamma_sync.3
diff --git a/doc/man/libcoopgamma_get_method_and_site.3 b/libcoopgamma_get_method_and_site.3
index 654db03..654db03 100644
--- a/doc/man/libcoopgamma_get_method_and_site.3
+++ b/libcoopgamma_get_method_and_site.3
diff --git a/doc/man/libcoopgamma_get_methods.3 b/libcoopgamma_get_methods.3
index b2ce807..b2ce807 100644
--- a/doc/man/libcoopgamma_get_methods.3
+++ b/libcoopgamma_get_methods.3
diff --git a/doc/man/libcoopgamma_get_pid_file.3 b/libcoopgamma_get_pid_file.3
index 3d312ef..3d312ef 100644
--- a/doc/man/libcoopgamma_get_pid_file.3
+++ b/libcoopgamma_get_pid_file.3
diff --git a/doc/man/libcoopgamma_get_socket_file.3 b/libcoopgamma_get_socket_file.3
index f73f0ca..f73f0ca 100644
--- a/doc/man/libcoopgamma_get_socket_file.3
+++ b/libcoopgamma_get_socket_file.3
diff --git a/doc/man/libcoopgamma_queried_filter_destroy.3 b/libcoopgamma_queried_filter_destroy.3
index 6847ac4..6847ac4 100644
--- a/doc/man/libcoopgamma_queried_filter_destroy.3
+++ b/libcoopgamma_queried_filter_destroy.3
diff --git a/doc/man/libcoopgamma_queried_filter_initialise.3 b/libcoopgamma_queried_filter_initialise.3
index 79f2c59..79f2c59 100644
--- a/doc/man/libcoopgamma_queried_filter_initialise.3
+++ b/libcoopgamma_queried_filter_initialise.3
diff --git a/doc/man/libcoopgamma_queried_filter_marshal.3 b/libcoopgamma_queried_filter_marshal.3
index 10b7ff7..10b7ff7 100644
--- a/doc/man/libcoopgamma_queried_filter_marshal.3
+++ b/libcoopgamma_queried_filter_marshal.3
diff --git a/doc/man/libcoopgamma_queried_filter_unmarshal.3 b/libcoopgamma_queried_filter_unmarshal.3
index 01f1867..01f1867 100644
--- a/doc/man/libcoopgamma_queried_filter_unmarshal.3
+++ b/libcoopgamma_queried_filter_unmarshal.3
diff --git a/doc/man/libcoopgamma_ramps_destroy.3 b/libcoopgamma_ramps_destroy.3
index 3d78d5d..3d78d5d 100644
--- a/doc/man/libcoopgamma_ramps_destroy.3
+++ b/libcoopgamma_ramps_destroy.3
diff --git a/doc/man/libcoopgamma_ramps_initialise.3 b/libcoopgamma_ramps_initialise.3
index f6ee3d2..f6ee3d2 100644
--- a/doc/man/libcoopgamma_ramps_initialise.3
+++ b/libcoopgamma_ramps_initialise.3
diff --git a/doc/man/libcoopgamma_ramps_marshal.3 b/libcoopgamma_ramps_marshal.3
index aed8509..aed8509 100644
--- a/doc/man/libcoopgamma_ramps_marshal.3
+++ b/libcoopgamma_ramps_marshal.3
diff --git a/doc/man/libcoopgamma_ramps_unmarshal.3 b/libcoopgamma_ramps_unmarshal.3
index 34393cf..34393cf 100644
--- a/doc/man/libcoopgamma_ramps_unmarshal.3
+++ b/libcoopgamma_ramps_unmarshal.3
diff --git a/doc/man/libcoopgamma_set_gamma_recv.3 b/libcoopgamma_set_gamma_recv.3
index 073343b..073343b 100644
--- a/doc/man/libcoopgamma_set_gamma_recv.3
+++ b/libcoopgamma_set_gamma_recv.3
diff --git a/doc/man/libcoopgamma_set_gamma_send.3 b/libcoopgamma_set_gamma_send.3
index 18c13f0..18c13f0 100644
--- a/doc/man/libcoopgamma_set_gamma_send.3
+++ b/libcoopgamma_set_gamma_send.3
diff --git a/doc/man/libcoopgamma_set_gamma_sync.3 b/libcoopgamma_set_gamma_sync.3
index e65e345..e65e345 100644
--- a/doc/man/libcoopgamma_set_gamma_sync.3
+++ b/libcoopgamma_set_gamma_sync.3
diff --git a/doc/man/libcoopgamma_set_nonblocking.3 b/libcoopgamma_set_nonblocking.3
index 7e6ceb6..7e6ceb6 100644
--- a/doc/man/libcoopgamma_set_nonblocking.3
+++ b/libcoopgamma_set_nonblocking.3
diff --git a/doc/man/libcoopgamma_skip_message.3 b/libcoopgamma_skip_message.3
index 13eb6cc..13eb6cc 100644
--- a/doc/man/libcoopgamma_skip_message.3
+++ b/libcoopgamma_skip_message.3
diff --git a/doc/man/libcoopgamma_synchronise.3 b/libcoopgamma_synchronise.3
index 70d2f63..70d2f63 100644
--- a/doc/man/libcoopgamma_synchronise.3
+++ b/libcoopgamma_synchronise.3
diff --git a/linux.mk b/linux.mk
new file mode 100644
index 0000000..5b97157
--- /dev/null
+++ b/linux.mk
@@ -0,0 +1,5 @@
+LIBEXT = so
+LIBFLAGS = -shared -Wl,-soname,libcoopgamma.$(LIBEXT).$(LIB_MAJOR)
+
+LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR)
+LIBMINOREXT = $(LIBEXT).$(LIB_VERSION)
diff --git a/macos.mk b/macos.mk
new file mode 100644
index 0000000..b475197
--- /dev/null
+++ b/macos.mk
@@ -0,0 +1,5 @@
+LIBEXT = dylib
+LIBFLAGS = -dynamiclib
+
+LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT)
+LIBMINOREXT = $(LIB_VERSION).$(LIBEXT)
diff --git a/man.mk b/man.mk
new file mode 100644
index 0000000..413c917
--- /dev/null
+++ b/man.mk
@@ -0,0 +1,64 @@
+MAN0 =\
+ libcoopgamma.h.0
+
+MAN3=\
+ libcoopgamma_async_context_destroy.3\
+ libcoopgamma_async_context_initialise.3\
+ libcoopgamma_async_context_marshal.3\
+ libcoopgamma_async_context_unmarshal.3\
+ libcoopgamma_connect.3\
+ libcoopgamma_context_destroy.3\
+ libcoopgamma_context_initialise.3\
+ libcoopgamma_context_marshal.3\
+ libcoopgamma_context_unmarshal.3\
+ libcoopgamma_crtc_info_destroy.3\
+ libcoopgamma_crtc_info_initialise.3\
+ libcoopgamma_crtc_info_marshal.3\
+ libcoopgamma_crtc_info_unmarshal.3\
+ libcoopgamma_error_destroy.3\
+ libcoopgamma_error_initialise.3\
+ libcoopgamma_error_marshal.3\
+ libcoopgamma_error_unmarshal.3\
+ libcoopgamma_filter_destroy.3\
+ libcoopgamma_filter_initialise.3\
+ libcoopgamma_filter_marshal.3\
+ libcoopgamma_filter_query_destroy.3\
+ libcoopgamma_filter_query_initialise.3\
+ libcoopgamma_filter_query_marshal.3\
+ libcoopgamma_filter_query_unmarshal.3\
+ libcoopgamma_filter_table_destroy.3\
+ libcoopgamma_filter_table_initialise.3\
+ libcoopgamma_filter_table_marshal.3\
+ libcoopgamma_filter_table_unmarshal.3\
+ libcoopgamma_filter_unmarshal.3\
+ libcoopgamma_flush.3\
+ libcoopgamma_get_crtcs_recv.3\
+ libcoopgamma_get_crtcs_send.3\
+ libcoopgamma_get_crtcs_sync.3\
+ libcoopgamma_get_gamma_info_recv.3\
+ libcoopgamma_get_gamma_info_send.3\
+ libcoopgamma_get_gamma_info_sync.3\
+ libcoopgamma_get_gamma_recv.3\
+ libcoopgamma_get_gamma_send.3\
+ libcoopgamma_get_gamma_sync.3\
+ libcoopgamma_get_method_and_site.3\
+ libcoopgamma_get_methods.3\
+ libcoopgamma_get_pid_file.3\
+ libcoopgamma_get_socket_file.3\
+ libcoopgamma_queried_filter_destroy.3\
+ libcoopgamma_queried_filter_initialise.3\
+ libcoopgamma_queried_filter_marshal.3\
+ libcoopgamma_queried_filter_unmarshal.3\
+ libcoopgamma_ramps_destroy.3\
+ libcoopgamma_ramps_initialise.3\
+ libcoopgamma_ramps_marshal.3\
+ libcoopgamma_ramps_unmarshal.3\
+ libcoopgamma_set_gamma_recv.3\
+ libcoopgamma_set_gamma_send.3\
+ libcoopgamma_set_gamma_sync.3\
+ libcoopgamma_set_nonblocking.3\
+ libcoopgamma_skip_message.3\
+ libcoopgamma_synchronise.3
+
+MAN7 =\
+ libcoopgamma.7
diff --git a/mk/README b/mk/README
deleted file mode 100644
index e79926d..0000000
--- a/mk/README
+++ /dev/null
@@ -1,71 +0,0 @@
-This is a collection of generic enough makefiles.
-Please feel free to use them in your project.
-
-Usage:
- Include all.mk from your makefile.
-
- Read the top of each file for details.
-
- Define the variables:
-
- _VERSION
- This version of the package.
-
- _PROJECT
- The name of the project. Must only include [a-z0-9_-].
-
- _PROJECT_FULL
- The name of the project. May include any character.
-
- _SRC
- All source code files. This list is used when
- generating the translation template file.
-
- _COPYRIGHT_HOLDER
- The copyright holder's full name and e-mail address.
-
- COMMAND
- The name of the command. Must not be declared if
- the package does not include exactly one runnable
- command.
-
- PKGNAME
- The name of the package.
-
- Variables beginning with __ are used internally by
- the files where they appear, or in rare cases,
- internally between these files.
-
- Variables beginning with _ but not __ are set in the
- makefile to specify for these files how they should
- behave. They should not be changed by a user of the
- package.
-
- Variables that do not begin with _ are configurable
- by the user of the package.
-
- Do no use single character variables in your Makefile.
-
- To suppress pre-install, post-install, pre-uninstall,
- and post-uninstall instructions, set N=true.
- PRE_INSTALL, POST_INSTALL, PRE_UNINSTALL, and
- POST_UNINSTALL are supportered as specified by the
- GNU coding standardars.
-
- To figure out what pre-install commands to run in your package, run:
- make -n a=% install | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To figure out what post-install commands to run in your package, run:
- make -n z=% uninstall | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To figure out what pre-uninstall commands to run in your package, run:
- make -n a=% uninstall | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To figure out what post-uninstall commands to run in your package, run:
- make -n z=% uninstall | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To suppress verbatim which commands Make runs,
- set Q=@. (Excluding the period.)
-
-Developers should use DEBUG=1 when running make, when possible.
-
diff --git a/mk/all.mk b/mk/all.mk
deleted file mode 100644
index 032718d..0000000
--- a/mk/all.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes all the other files in appropriate order. ===#
-
-
-ifndef Q
-A = \e[35m
-Z = 
-endif
-
-include $(v)mk/path.mk
-include .config.mk
-include $(v)mk/path.mk
-include $(v)mk/lowerpath.mk
-include $(v)mk/empty.mk
-include $(v)mk/tools.mk
-include $(v)mk/copy.mk
-include $(v)mk/lang-c.mk
-include $(v)mk/texinfo.mk
-include $(v)mk/man.mk
-include $(v)mk/i18n.mk
-include $(v)mk/clean.mk
-include $(v)mk/dist.mk
-include $(v)mk/tags.mk
-include $(v)mk/prologue.mk
-
diff --git a/mk/clean.mk b/mk/clean.mk
deleted file mode 100644
index 1ae4fdc..0000000
--- a/mk/clean.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for cleaning the repository of generated files. ===#
-
-
-# Delete all files are normally created during a build.
-.PHONY: clean
-clean: clean-dist
- @$(PRINTF_INFO) '\e[00;01;31mCLEANING BUILT FILES\e[34m\e[00m\n'
- -$(Q)$(RM) -r -- bin aux *.su src/*.su src/*/*.su src/*/*/*.su src/*/*/*/*.su
- @$(ECHO)
-
-# Delete all files that are created during configuration or building.
-.PHONY: distclean
-distclean: clean
- @$(PRINTF_INFO) '\e[00;01;31mCLEANING CONFIGURATIONS\e[34m\e[00m\n'
- -$(Q)$(RM) -- .config.mk config.status Makefile
- @$(ECHO)
-
-# Like `make clean` but do not remove massive binaries
-# that are seldom recompiled.
-.PHONY: mostlyclean
-mostlyclean: clean
-
-# Delete everything except ./configure
-.PHONY: maintainer-clean
-maintainer-clean: clean distclean
- @$(ECHO)
- @$(ECHO) 'This command is intended for maintainers to use; it'
- @$(ECHO) 'deletes files that may need special tools to rebuild.'
- @$(ECHO)
-
-# Delete all files generated by `make dist`
-.PHONY: clean-dist
-clean-dist:
- @$(PRINTF_INFO) '\e[00;01;31mCLEANING RELEASES\e[34m\e[00m\n'
- -$(Q)$(RM) -r -- $(_PROJECT)-*.tar* $(_PROJECT)-*.checksums* $(_PROJECT)-*
- @$(ECHO)
-
diff --git a/mk/configure b/mk/configure
deleted file mode 100644
index 4b6e61a..0000000
--- a/mk/configure
+++ /dev/null
@@ -1,732 +0,0 @@
-# -*- shell-script -*-
-
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# Run './configure --help' for usage information.
-
-
-# FOR DEVELOPERS USING THIS SCRIPT:
-# This file is used by include this file, via the . builtin,
-# in your ./configure. Before doing so, you must declare
-# PKGNAME=the_name_of_your_package
-# MAN_SECTION_SUFFIX=default_suffix_to_append_to_man_page_section # (usually empty)
-# MAN_SECTION=the_section_your_man_page_is_in # (do no declare if you do not use exacly one section)
-# Define the function list_optional_features_help, see the help output.
-# Define the function unrecognised_argument to deal with any unrecognised argument.
-
-
-
-# Store command for rebuilding Makefile to config.status.
-exec 10>config.status
-
-# Store configurations to .config.mk.
-exec 20>.config.mk
-
-
-# Print a quoted (if necessary) version of a string
-quote ()
-{
- value="$1"
- if ! test "${value%%\'*}" = "${value}"; then
- value="'$(echo "${value}" | sed "s/'/'\\\\''/g")'"
- elif ! test "$(printf '%s' ${value})" = "${value}"; then
- value="'${value}'"
- elif ! test "$(echo ${value}) | tr -d a-zA-Z0-9+_@%/=-" = ""; then
- value="'${value}'"
- fi
- echo "${value}"
-}
-
-
-# Parse command line.
-incomplete=
-dashed=
-f_help=
-f_gnulinux=
-f_bin_merger=
-for option; do
- if test -n "${incomplete}"; then
- option="${incomplete}=${option}"
- incomplete=
- fi
-
- # For --{with{,out},{en,dis}able}-*.
- feature="${option#--*}"
- feature="${feature#*-}"
- feature="$(echo "${feature}" | tr a-z- A-Z_)"
-
- # For directories and filename tweaks.
- nodash=_novar
-
- case "${dashed}${option}" in
-# general
- (--)
- dashed=yes ;;
- (--help)
- f_help=yes ;;
- (--destdir | --destdir=* | --pkgdir | --pkgdir=*)
- nodash=destdir ;;
- (--srcdir | --srcdir)
- nodash=srcdir ;;
-
-# directory automation
- (--gnu-linux)
- f_gnulinux=yes ;;
- (--bin-merger)
- f_bin_merger=yes ;;
-
-# directories and filenames
- (--prefix | --prefix=*)
- nodash=prefix ;;
- (--exec-prefix | --exec-prefix=* | --exec_prefix | --exec_prefix=*)
- nodash=exec_prefix ;;
- (--bindir | --bindir=*)
- nodash=bindir ;;
- (--sbindir | --sbindir=*)
- nodash=sbindir ;;
- (--libexecdir | --libexecdir=*)
- nodash=libexecdir ;;
- (--libdir | --libdir=*)
- nodash=libdir ;;
- (--includedir | --includedir=*)
- nodash=includedir ;;
- (--oldincludedir | --oldincludedir=*)
- nodash=oldincludedir ;;
- (--datarootdir | --datarootdir=*)
- nodash=datarootdir ;;
- (--datadir | --datadir=*)
- nodash=datadir ;;
- (--libdatarootdir | --libdatarootdir=*)
- nodash=libdatarootdir ;;
- (--libdatadir | --libdatadir=*)
- nodash=libdatadir ;;
- (--sysconfdir | --sysconfdir=*)
- nodash=sysconfdir ;;
- (--sharedstatedir | --=sharedstatedir*)
- nodash=sharedstatedir ;;
- (--localstatedir | --localstatedir=*)
- nodash=localstatedir ;;
- (--runstatedir | --runstatedir=*)
- nodash=runstatedir ;;
- (--lispdir | --lispdir=*)
- nodash=lispdir ;;
- (--localedir | --localedir=*)
- nodash=localedir ;;
- (--licensedir | --licensedir=*)
- nodash=licensedir ;;
- (--emptydir | --emptydir=*)
- nodash=emptydir ;;
- (--cachedir | --cachedir=*)
- nodash=cachedir ;;
- (--spooldir | --spooldir=*)
- nodash=spooldir ;;
- (--logdir | --logdir=*)
- nodash=logdir ;;
- (--statedir | --statedir=*)
- nodash=statedir ;;
- (--gamedir | --gamedir=*)
- nodash=gamedir ;;
- (--sharedcachedir | --sharedcachedir=*)
- nodash=sharedcachedir ;;
- (--sharedspooldir | --sharedspooldir=*)
- nodash=sharedspooldir ;;
- (--sharedlogdir | --sharedlogdir=*)
- nodash=sharedlogdir ;;
- (--sharedstatedir | --sharedstatedir=*)
- nodash=sharedstatedir ;;
- (--sharedgamedir | --sharedgamedir=*)
- nodash=sharedgamedir ;;
- (--tmpdir | --tmpdir=*)
- nodash=tmpdir ;;
- (--localtmpdir | --localtmpdir=*)
- nodash=localtmpdir ;;
- (--sharedtmpdir | --sharedtmpdir=*)
- nodash=sharedtmpdir ;;
- (--lockdir | --lockdir=*)
- nodash=lockdir ;;
- (--skeldir | --skeldir=*)
- nodash=skeldir ;;
- (--devdir | --devdir=*)
- nodash=devdir ;;
- (--sysdir | --sysdir=*)
- nodash=sysdir ;;
- (--procdir | --procdir=*)
- nodash=procdir ;;
- (--selfprocdir | --selfprocdir=*)
- nodash=selfprocdir ;;
- (--docdir | --docdir=*)
- nodash=docdir ;;
- (--infodir | --infodir=*)
- nodash=infodir ;;
- (--dvidir | --dvidir=*)
- nodash=dvidir ;;
- (--pdfdir | --pdfdir=*)
- nodash=pdfdir ;;
- (--psdir | --psdir=*)
- nodash=psdir ;;
- (--htmldir | --htmldir=*)
- nodash=htmldir ;;
- (--mandir | --mandir=*)
- nodash=mandir ;;
- (--man0 | --man0=*)
- nodash=man0 ;;
- (--man1 | --man1=*)
- nodash=man1 ;;
- (--man2 | --man2=*)
- nodash=man2 ;;
- (--man3 | --man3=*)
- nodash=man3 ;;
- (--man4 | --man4=*)
- nodash=man4 ;;
- (--man5 | --man5=*)
- nodash=man5 ;;
- (--man6 | --man6=*)
- nodash=man6 ;;
- (--man7 | --man7=*)
- nodash=man7 ;;
- (--man8 | --man8=*)
- nodash=man8 ;;
- (--man9 | --man9=*)
- nodash=man9 ;;
- (--man0ext | --man0ext=*)
- nodash=man0ext ;;
- (--man1ext | --man1ext=*)
- nodash=man1ext ;;
- (--man2ext | --man2ext=*)
- nodash=man2ext ;;
- (--man3ext | --man3ext=*)
- nodash=man3ext ;;
- (--man4ext | --man4ext=*)
- nodash=man4ext ;;
- (--man5ext | --man5ext=*)
- nodash=man5ext ;;
- (--man6ext | --man6ext=*)
- nodash=man6ext ;;
- (--man7ext | --man7ext=*)
- nodash=man7ext ;;
- (--man8ext | --man8ext=*)
- nodash=man8ext ;;
- (--man9ext | --man9ext=*)
- nodash=man9ext ;;
- (--manext | --manext=*)
- if test -n "${MAN_SECTION}"; then
- nodash=manext
- else
- printf "\e[01;31m%s: warning: ignoring: %s\e[00m\n" "${0}" "${option}" >&2
- sleep 1
- fi
- ;;
-
-# ignored
- # Unrecognised directories, and settings that cannot be used with internationalisation.
- (--*dir=* | --*dir | --man?dir | --man?dir=*)
- printf "\e[01;31m%s: warning: ignoring: %s\e[00m\n" "${0}" "${option}" >&2
- sleep 1
- ;;
-
-# feature tweaking
- (--with-*)
- feature="WITH_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
- (--without-*)
- feature="WITHOUT_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
- (--enable-*=*)
- param="${feature#*=}"
- feature="${feature%%=*}"
- if ! test "${param}" = "no"; then
- feature="ENABLE_${feature}"
- else
- feature="DISABLE_${feature}"
- param=yes
- fi
- echo "${feature}" = "${param}" >&20
- export "${feature}"="${param}"
- ;;
-
- (--enable-*)
- feature="DISABLE_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
- (--disable-*)
- feature="DISABLE_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
-# unrecognised
- (${dashed}--*)
- unrecognised_argument "${option}"
- ;;
-
-# variables
- (${dashed}*=*)
- var="${option%%=*}"
- val="${option#*=}"
- if test -n "$(echo "${var}" | tr -d '[_a-zA-Z0-9-]')"; then
- # Variable is not used and is potentially not
- # formatted in a compatible way.
- printf "\e[01;31m%s: warning: ignoring because of bad format: %s\e[00m\n" "${0}" "${option}" >&2
- sleep 1
- fi
- echo "${var}" = "${val}" >&20
- ;;
-
-# unrecognised
- (*)
- unrecognised_argument "${option}"
- ;;
- esac
-
- if test "${option%%=*}" = "${option}"; then
- incomplete="${option}"
- else
- eval "${nodash}=$(quote "${option#*=}")"
- eval "have_${nodash}=yes"
- fi
-done
-
-
-# Print usage information. This is parsed by
-# the auto-completion script for ./configure.
-if test -n "${f_help}"; then
- cat <<EOF
-Configure the package (${PKGNAME}) before building and installing.
-
-OPTIONS
-
-general
- --help Print usage information.
- --destdir=DIR Output directory for staged install.
- --srcdir=DIR The directory for the sources being compiled.
- VARIABLE=VALUE Override a variable in the Makefile.
-
-directory automation
- --gnu-linux Use default configurations for GNU/Linux.
- --bin-merger The OS distribution has symlinked sbin to bin for the select exec-prefix.
-
-tweaking of features
-EOF
- list_optional_features_help
- cat <<EOF
-
-tweaking of directories and filenames
- --prefix=DIR Prefix used for other directories than.
- --exec-prefix=DIR Prefix used for /bin, /sbin, /libexec, and /lib.
- --bindir=DIR Executable programs that users can run.
- --sbindir=DIR Executable administrative programs.
- --libexecdir=DIR Executable programs run by other programs and not be users.
- --libdir=DIR Object files and libraries of object code.
- --includedir=DIR Header files.
- --oldincludedir=DIR Header files. Should have the prefix /usr if the canonical prefix is /usr/local.
- --datarootdir=DIR Architecture-independent data files.
- --datadir=DIR Architecture-independent resource files.
- --libdatarootdir=DIR Architecture-dependent data files.
- --libdatadir=DIR Architecture-dependent resource files.
- --sysconfdir=DIR Machine-local configuration files.
- --sharedstatedir=DIR Network-shared architecture-independent state files.
- --localstatedir=DIR Machine-local architecture-independent state files.
- --runstatedir=DIR Machine-local runtime state files.
- --lispdir=DIR Emacs LISP files.
- --localedir=DIR Locale-specific message catalogues.
- --licensedir=DIR License files.
- --emptydir=DIR An always empty directory.
- --cachedir=DIR Machine-local cached files.
- --spooldir=DIR Machine-local spooled files.
- --logdir=DIR Machine-local log files
- --statedir=DIR Machine-local persistent state files
- --gamedir=DIR Machine-local highscore files.
- --sharedcachedir=DIR Network-shared cached files.
- --sharedspooldir=DIR Network-shared spooled files.
- --sharedlogdir=DIR Network-shared log files
- --sharedstatedir=DIR Network-shared persistent state files
- --sharedgamedir=DIR Network-shared highscore files.
- --tmpdir=DIR Machine-local volatile temporary files.
- --localtmpdir=DIR Machine-local persistent temporary files.
- --sharedtmpdir=DIR Network-shared temporary files.
- --lockdir=DIR Lock files.
- --skeldir=DIR User skeleton.
- --devdir=DIR Devices and pseudo-devices.
- --sysdir=DIR System-information logical file.
- --procdir=DIR Process-information logical file.
- --selfprocdir=DIR Process-information logical file for the process itself.
- --docdir=DIR Documentation files, other then info manuals and man pages.
- --infodir=DIR Info manuals.
- --dvidir=DIR DVI manuals.
- --pdfdir=DIR PDF manuals.
- --psdir=DIR PostScript manuals.
- --htmldir=DIR HTML manuals.
- --mandir=DIR Top-level directory for man pages.
- --man0=DIR Basename of the directory for section 0 man pages.
- --man1=DIR Basename of the directory for section 1 man pages.
- --man2=DIR Basename of the directory for section 2 man pages.
- --man3=DIR Basename of the directory for section 3 man pages.
- --man4=DIR Basename of the directory for section 4 man pages.
- --man5=DIR Basename of the directory for section 5 man pages.
- --man6=DIR Basename of the directory for section 6 man pages.
- --man7=DIR Basename of the directory for section 7 man pages.
- --man8=DIR Basename of the directory for section 8 man pages.
- --man9=DIR Basename of the directory for section 9 man pages.
-EOF
- if test -n "${MAN_SECTION}"; then
- cat <<EOF
- --manext=EXT Filename suffix for the man page.
-EOF
- fi
- cat <<EOF
- --man0ext=EXT Filename suffix for section 0 man pages.
- --man1ext=EXT Filename suffix for section 1 man pages.
- --man2ext=EXT Filename suffix for section 2 man pages.
- --man3ext=EXT Filename suffix for section 3 man pages.
- --man4ext=EXT Filename suffix for section 4 man pages.
- --man5ext=EXT Filename suffix for section 5 man pages.
- --man6ext=EXT Filename suffix for section 6 man pages.
- --man7ext=EXT Filename suffix for section 7 man pages.
- --man8ext=EXT Filename suffix for section 8 man pages.
- --man9ext=EXT Filename suffix for section 9 man pages.
-EOF
- exit 0
-fi
-
-
-# Set unset directories to their default.
-defdir ()
-{
- p="$(quote "${2}")"
- if ! test -n "$(eval echo '${have_'"${1}"'}')"; then
- eval "${1}=${p}"
- fi
-}
-if test -n "${f_gnulinux}"; then
- defdir prefix "/usr"
- _prefix=
- case ${prefix} in
- ('' | / | /usr | /usr/ | /games | /games | /usr/games | /usr/games/)
- _infix=
- ;;
- (/usr/local | /usr/local/ | /usr/local/games | /usr/local/games/)
- _infix=/local
- ;;
- (/opt/*)
- _infix=${prefix}
- ;;
- (*)
- # This probably means somewhere in /home, we do not
- # checked because we do not know what else to do.
- _infix=
- _prefix="${prefix}"
- ;;
- esac
- defdir sysconfdir "${_prefix}/etc${_infix}"
- defdir sharedstatedir "${_prefix}/com${_infix}"
- defdir localstatedir "${_prefix}/var${_infix}"
- defdir runstatedir "${_prefix}/run${_infix}"
- defdir tmpdir "${_prefix}/tmp${_infix}"
-else
- defdir prefix "/usr/local"
- defdir sysconfdir "${prefix}/etc"
- defdir sharedstatedir "${prefix}/com"
- defdir localstatedir "${prefix}/var"
- defdir runstatedir "${localstatedir}/run"
- defdir tmpdir "${prefix}/tmp"
-fi
-defdir exec_prefix "${prefix}"
-defdir bindir "${exec_prefix}/bin"
-if test -n "${f_bin_merger}"; then
- defdir sbindir "${bindir}"
-else
- defdir sbindir "${exec_prefix}/sbin"
-fi
-defdir libexecdir "${exec_prefix}/libexec"
-defdir libdir "${exec_prefix}/lib"
-defdir includedir "${prefix}/include"
-defdir oldincludedir "${includedir}"
-defdir datarootdir "${prefix}/share"
-defdir datadir "${datarootdir}"
-defdir libdatarootdir "${libdir}"
-defdir libdatadir "${libdir}"
-defdir lispdir "${datarootdir}/emacs/site-lisp"
-defdir localedir "${datarootdir}/locale"
-defdir licensedir "${datarootdir}/licenses"
-defdir cachedir "${localstatedir}/cache"
-defdir spooldir "${localstatedir}/spool"
-defdir emptydir "${localstatedir}/empty"
-defdir logdir "${localstatedir}/log"
-defdir statedir "${localstatedir}/lib"
-defdir gamedir "${localstatedir}/games"
-defdir sharedcachedir "${sharedstatedir}/cache"
-defdir sharedpooldir "${sharedstatedir}/spool"
-defdir sharedlogdir "${sharedstatedir}/log"
-defdir sharedstatedir "${sharedstatedir}/lib"
-defdir sharedgamedir "${sharedstatedir}/games"
-defdir localtmpdir "${localstatedir}/tmp"
-defdir sharedtmpdir "${sharedstatedir}/tmp"
-defdir lockdir "${runstatedir}/lock"
-defdir skeldir "${sysconfdir}/skel"
-defdir devdir "/dev"
-defdir sysdir "/sys"
-defdir procdir "/proc"
-defdir selfprocdir "${procdir}/self"
-defdir docdir "${datarootdir}/doc/${PKGNAME}"
-defdir infodir "${datarootdir}/info"
-defdir dvidir "${docdir}"
-defdir pdfdir "${docdir}"
-defdir psdir "${docdir}"
-defdir htmldir "${docdir}"
-defdir mandir "${datarootdir}/man"
-defdir man0 "man0${MAN_SECTION_SUFFIX}"
-defdir man1 "man1${MAN_SECTION_SUFFIX}"
-defdir man2 "man2${MAN_SECTION_SUFFIX}"
-defdir man3 "man3${MAN_SECTION_SUFFIX}"
-defdir man4 "man4${MAN_SECTION_SUFFIX}"
-defdir man5 "man5${MAN_SECTION_SUFFIX}"
-defdir man6 "man6${MAN_SECTION_SUFFIX}"
-defdir man7 "man7${MAN_SECTION_SUFFIX}"
-defdir man8 "man8${MAN_SECTION_SUFFIX}"
-defdir man9 "man9${MAN_SECTION_SUFFIX}"
-if test -n "${MAN_SECTION}" && ! test -n "$(eval echo '${man'"${MAN_SECTION}"'ext}')"; then
- defdir "man${MAN_SECTION}ext" "$(eval echo '${man'"${MAN_SECTION}"'ext}')"
-fi
-defdir man0ext ".0"
-defdir man1ext ".1"
-defdir man2ext ".2"
-defdir man3ext ".3"
-defdir man4ext ".4"
-defdir man5ext ".5"
-defdir man6ext ".6"
-defdir man7ext ".7"
-defdir man8ext ".8"
-defdir man9ext ".9"
-
-# Found source directory.
-if ! test -n "${srcdir}"; then
- if test -f "Makefile.in"; then
- :
- elif test -f "${PWD}/Makefile.in"; then
- srcdir="${PWD}"
- elif test -f "${PWD}/../Makefile.in"; then
- srcdir="${PWD}/.."
- fi
-fi
-if test -n "${srcdir}"; then
- srcdir="$(realpath "${srcdir}")/"
- srcdir_proper="${srcdir}"
- srcdir="$(quote "${srcdir}")"
-fi
-if ! test -f "${srcdir_proper}Makefile.in"; then
- echo "${0}: error: cannot found source directory."
- exit 1
-fi
-
-
-# Add shebang and "generated"-comment to config.status.
-echo '#!/bin/sh' >&10
-echo >&10
-echo '# This file was generated by ./configure, its purpose is two-fold:' >&10
-echo '# 1) It lets you rebuild Makefile with the same configurations you' >&10
-echo '# used last time you run ./configure.' >&10
-echo '# 2) It lets Makefile rebuild itself transparently when out of date.' >&10
-echo >&10
-
-# config.status should adjust CWD.
-echo 'cd "$(dirname "${0}")"' >&10
-
-# config.status calls ./configure with all arguments you called ./configure.
-printf "exec %s" "${0}" >&10
-for option; do
- printf " %s" "$(quote "${option}")" >&10
-done
-echo >&10
-
-# Close config.status.
-exec 10>&-
-
-
-# Store environment (with restrictions).
-env | while read line; do
- var="${line%%=*}"
- val="${line#*=}"
- if test "${var}" = "${line}"; then
- # Malformated variables. (Can happen!, sigh...)
- continue
- elif test -n "$(echo "${var}" | tr -d '[_a-zA-Z0-9-]')"; then
- # Variable is not used and is potentially not
- # formatted in a compatible way.
- continue
- fi
- case "${var}" in
- (_ | PWD | SHELL | SHLVL | TERM | COLORTERM | MAKEFLAGS)
- # We do not want to propagate these.
- ;;
- (*)
- echo "${var}" = "${val}" >&20
- ;;
- esac
-done
-
-# Store directories and filenames.
-if test -n "${destdir}"; then
- echo DESTDIR = "${destdir}" >&20
-fi
-echo PREFIX = "${prefix}" >&20
-echo SYSCONFDIR = "${sysconfdir}" >&20
-echo COMDIR = "${sharedstatedir}" >&20
-echo VARDIR = "${localstatedir}" >&20
-echo RUNDIR = "${runstatedir}" >&20
-echo TMPDIR = "${tmpdir}" >&20
-echo DEVDIR = "${devdir}" >&20
-echo SYSDIR = "${sysdir}" >&20
-echo PROCDIR = "${procdir}" >&20
-echo EXEC_PREFIX = "${exec_prefix}" >&20
-echo BINDIR = "${bindir}" >&20
-echo SBINDIR = "${sbindir}" >&20
-echo LIBEXECDIR = "${libexecdir}" >&20
-echo LIBDIR = "${libdir}" >&20
-echo INCLUDEDIR = "${includedir}" >&20
-echo OLDINCLUDEDIR = "${oldincludedir}" >&20
-echo DATADIR = "${datarootdir}" >&20
-echo RESDIR = "${datadir}" >&20
-echo SYSDEPDATADIR = "${libdatarootdir}" >&20
-echo SYSDEPRESDIR = "${libdatadir}" >&20
-echo LISPDIR = "${lispdir}" >&20
-echo LOCALEDIR = "${localedir}" >&20
-echo LICENSEDIR = "${licensedir}" >&20
-echo CACHEDIR = "${cachedir}" >&20
-echo SPOOLDIR = "${spooldir}" >&20
-echo EMPTYDIR = "${emptydir}" >&20
-echo LOGDIR = "${logdir}" >&20
-echo STATEDIR = "${statedir}" >&20
-echo GAMEDIR = "${gamedir}" >&20
-echo COMCACHEDIR = "${sharedcachedir}" >&20
-echo COMPOOLDIR = "${sharedpooldir}" >&20
-echo COMLOGDIR = "${sharedlogdir}" >&20
-echo COMSTATEDIR = "${sharedstatedir}" >&20
-echo COMGAMEDIR = "${sharedgamedir}" >&20
-echo LOCALTMPDIR = "${localtmpdir}" >&20
-echo SHAREDTMPDIR = "${sharedtmpdir}" >&20
-echo LOCKDIR = "${lockdir}" >&20
-echo SKELDIR = "${skeldir}" >&20
-echo SELFPROCDIR = "${selfprocdir}" >&20
-echo DOCDIR = "${docdir}" >&20
-echo INFODIR = "${infodir}" >&20
-echo DVIDIR = "${dvidir}" >&20
-echo PDFDIR = "${pdfdir}" >&20
-echo PSDIR = "${psdir}" >&20
-echo HTMLDIR = "${htmldir}" >&20
-echo MANDIR = "${mandir}" >&20
-echo MAN0 = "${man0}" >&20
-echo MAN1 = "${man1}" >&20
-echo MAN2 = "${man2}" >&20
-echo MAN3 = "${man3}" >&20
-echo MAN4 = "${man4}" >&20
-echo MAN5 = "${man5}" >&20
-echo MAN6 = "${man6}" >&20
-echo MAN7 = "${man7}" >&20
-echo MAN8 = "${man8}" >&20
-echo MAN9 = "${man9}" >&20
-echo MAN0EXT = "${man0ext}" >&20
-echo MAN1EXT = "${man1ext}" >&20
-echo MAN2EXT = "${man2ext}" >&20
-echo MAN3EXT = "${man3ext}" >&20
-echo MAN4EXT = "${man4ext}" >&20
-echo MAN5EXT = "${man5ext}" >&20
-echo MAN6EXT = "${man6ext}" >&20
-echo MAN7EXT = "${man7ext}" >&20
-echo MAN8EXT = "${man8ext}" >&20
-echo MAN9EXT = "${man9ext}" >&20
-
-# Close .config.mk.
-exec 20>&-
-
-# Now, make Makefile available.
-if test -f Makefile; then
- chmod u+w Makefile # This scripts makes it read-only.
-fi
-exec 30>Makefile
-echo "# ----------------------------------------------------- #" >&30
-echo "# This file was created by ./configure from Makefile.in #" >&30
-echo "# ----------------------------------------------------- #" >&30
-echo >&30
-if test -n "${srcdir}"; then
- echo v = "${srcdir}" >&30
-fi
-cat "${srcdir_proper}"Makefile.in >&30
-exec 30>&-
-
-
-# config.status should be executable.
-chmod a+x config.status
-
-# Makefile should be read-only to ones does not edit it by mistake.
-chmod a-w Makefile
-
-
-# Help functions for the parent script.
-test_with ()
-{
- with="$(eval echo '${WITH_'"${1}"'}')"
- without="$(eval echo '${WITHOUT_'"${1}"'}')"
- if ! test -n "${with}" && ! test -n "${without}"; then
- echo "${2}"
- elif ! test -n "${with}" && test -n "${without}"; then
- echo "no"
- elif test -n "${with}" && ! test -n "${without}"; then
- echo "yes"
- elif test "${2}" = yes; then
- echo "no"
- else
- echo "yes"
- fi
-}
-test_enable ()
-{
- enable="$(eval echo '${ENABLE_'"${1}"'}')"
- disable="$(eval echo '${DISABLE_'"${1}"'}')"
- if ! test -n "${enable}" && ! test -n "${disable}"; then
- echo "${2}"
- elif ! test -n "${enable}" && test -n "${disable}"; then
- echo "no"
- elif test -n "${enable}" && ! test -n "${disable}"; then
- echo "${enable}"
- elif test "${2}" = yes ; then
- echo "no"
- else
- echo "${enable}"
- fi
-}
-
-
-# After including this file, you may want
-# to do something like:
-#
-# cat <<EOF
-#
-# Enabled features, see ${0} for more infomation:
-#
-# Internationalisation $(test_with GETTEXT yes)
-# GNU Bash tab-completion $(test_with BASH yes)
-# Fish tab-completion $(test_with FISH yes)
-# Z shell tab-completion $(test_with ZSH yes)
-#
-# You can now run 'make && make install'.
-#
-# EOF
-
diff --git a/mk/copy.mk b/mk/copy.mk
deleted file mode 100644
index c9067a4..0000000
--- a/mk/copy.mk
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for legal files. ===#
-
-
-# Enables the rules:
-# install-copyright Install all files in _COPYING and _LICENSE
-# install-copying Install all files in _COPYING
-# install-license Install all files in _LICENSE
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-install-base: install-copyright
-uninstall: uninstall-copyright
-
-
-# INSTALL RULES:
-
-.PHONY: install-copyright
-install-copyright:
-
-ifdef _COPYING
-.PHONY: install-copyright
-install-copyright: install-copying
-
-.PHONY: install-copying
-install-copying: $(foreach F,$(_COPYING),$(v)$(F))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- @$(ECHO_EMPTY)
-endif
-
-ifdef _LICENSE
-.PHONY: install-copyright
-install-copyright: install-license
-
-.PHONY: install-license
-install-license: $(foreach F,$(_LICENSE),$(v)$(F))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- @$(ECHO_EMPTY)
-endif
-
-
-# UNINSTALL RULES:
-
-.PHONY: uninstall-copyright
-uninstall-copyright:
-
-ifdef _COPYING
-.PHONY: uninstall-copyright
-uninstall-copyright: uninstall-copying
-
-.PHONY: uninstall-copying
-uninstall-copying:
- -$(Q)$(RM) -- $(foreach F,$(_COPYING),"$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/$(F)")
- -$(Q)$(RMDIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-endif
-
-ifdef _LICENSE
-.PHONY: uninstall-copyright
-uninstall-copyright: uninstall-license
-
-.PHONY: uninstall-license
-uninstall-license:
- -$(Q)$(RM) -- $(foreach F,$(_LICENSE),"$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/$(F)")
- -$(Q)$(RMDIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-endif
-
diff --git a/mk/dist.mk b/mk/dist.mk
deleted file mode 100644
index 9f8c48b..0000000
--- a/mk/dist.mk
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for making releases. ===#
-
-
-# CONFIGURATIONS:
-
-# Formats for packages to generate.
-DIST_FORMATS = tar tar.xz tar.bz2 tar.gz
-
-# Define DO_NOT_SIGN if you do not want sign the release.
-
-# You can select checksums to generate:
-# Declaring NO_BSD_SUM will omit `sum -r`.
-# Declaring NO_SYSV_SUM will omit `sum -s`.
-# List all checksum programs, that do not require any flags, in DIST_CHECKSUMS.
-
-# Any missing flags for GnuPG?
-GPG_FLAGS =
-
-# What key should be used for signing?
-GPG_KEY ?=
-
-# You should define _EVERYTHING to enumerate all files that belong in
-# the release tarball, lest 'git archive' will be used as a fallback.
-
-
-
-# HELP VARIALES:
-
-# You may use these to help list all files in _EVERYTHING
-__EVERYTHING_COMMON = $(_COPYING) $(_LICENSE) README
-__EVERYTHING_SRC = $(foreach F,$(_SRC),src/$(F))
-__EVERYTHING_LOCALE = $(foreach L,$(LOCALES),po/$(L).po)
-__EVERYTHING_SHELL = $(foreach F,$(_AUTO_COMPLETE),src/$(F).auto-completion) \
- $(foreach F,$(_AUTO_COMPLETE),$(foreac F,$(_SHELL_LOCALES),src/$(F).$(L),auto-completion))
-__EVERYTHING_MK_ = all clean copy dist empty i18n lang-c lowerpath man path prologue shell tags texinfo tools
-__EVERYTHING_MK = $(foreach F,$(__EVERYTHING_MK_),mk/$(F).mk) mk/configure mk/README configure Makefile.in
-__EVERYTHING_MAN = $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),doc/man/$(P).$(S))) \
- $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach L,$(MAN_LOCALES),$(foreach P,$(_MAN_$(L)_$(S)),doc/man/$(P).$(L).$(S))))
-__EVERYTHING_ALL_COMMON = $(__EVERYTHING_COMMON) $(__EVERYTHING_MK) $(__EVERYTHING_MAN) \
- $(__EVERYTHING_LOCALE) $(__EVERYTHING_SRC) $(__EVERYTHING_SHELL)
-# This one (__todo) if you have a todo file, but do not want it to be greped.
-__TO__ = TO
-__DO__ = DO
-__todo = $(__TO__)$(__DO__)
-
-
-# The packages and there detached signatures (if any.)
-ifndef DO_NOT_SIGN
-__DIST_FILES = $(foreach F,$(DIST_FORMATS),$(_PROJECT)-$(_VERSION).$(F) $(_PROJECT)-$(_VERSION).$(F).sig)
-endif
-ifdef DO_NOT_SIGN
-__DIST_FILES = $(foreach F,$(DIST_FORMATS),$(_PROJECT)-$(_VERSION).$(F))
-endif
-
-# All known checksum programs that are unambiguous.
-__DIST_CHECKSUMS_ALL = cksum md2sum md4sum md5sum md6sum sha0sum sha1sum sha224sum \
- sha256sum sha384sum sha512sum sha512-224sum sha512-256sum \
- sha3-224sum sha3-256sum sha3-384sum sha3-512sum shake256sum \
- shake512sum rawshake256sum rawshake512sum keccak-224sum \
- keccak-256sum keccak-384sum keccak-512sum keccaksum
-
-# All installed checksum programs that are unambiguous.
-DIST_CHECKSUMS = $(foreach C,$(__DIST_CHECKSUMS_ALL),$(shell if command -v $(C) >/dev/null; then $(ECHO) $(C); fi))
-
-
-
-# MAKE RULES:
-
-# Generate release files. (Tarballs, compressed and uncompressed; signatures; checksums.)
-.PHONY: dist
-dist: dist-balls dist-checksums
-
-
-
-# HELP MAKE RULES:
-
-# Generate tarballs, compressed and uncompressed,
-.PHONY: dist-balls
-dist-balls: $(__DIST_FILES)
-
-ifndef DO_NOT_SIGN
-# Generate checksums and signature of checksums.
-.PHONY: dist-checksums
-dist-checksums: $(_PROJECT)-$(_VERSION).checksums $(_PROJECT)-$(_VERSION).checksums.sig
-
-# Generate uncompressed tarball and signature of it.
-.PHONY: dist-tar
-dist-tar: $(_PROJECT)-$(_VERSION).tar $(_PROJECT)-$(_VERSION).tar.sig
-
-# Generate xz-copressed tarball and signature of it.
-.PHONY: dist-xz
-dist-xz: $(_PROJECT)-$(_VERSION).tar.xz $(_PROJECT)-$(_VERSION).tar.xz.sig
-
-# Generate bz2-copressed tarball and signature of it.
-.PHONY: dist-bzip2
-dist-bz2: $(_PROJECT)-$(_VERSION).tar.bz2 $(_PROJECT)-$(_VERSION).tar.bz2.sig
-
-# Generate gzip-copressed tarball and signature of it.
-.PHONY: dist-gz
-dist-gz: $(_PROJECT)-$(_VERSION).tar.gz $(_PROJECT)-$(_VERSION).tar.sig
-endif
-ifdef DO_NOT_SIGN
-# Generate checksums, but no signature.
-.PHONY: dist-checksums
-dist-checksums: $(_PROJECT)-$(_VERSION).checksums
-
-# Generate uncompressed tarball, but no signature.
-.PHONY: dist-tar
-dist-tar: $(_PROJECT)-$(_VERSION).tar
-
-# Generate xz-compressed tarball, but no signature.
-.PHONY: dist-xz
-dist-xz: $(_PROJECT)-$(_VERSION).tar.xz
-
-# Generate bzip2-compressed tarball, but no signature.
-.PHONY: dist-bz2
-dist-bz2: $(_PROJECT)-$(_VERSION).tar.bz2
-
-# Generate gzip-compressed tarball, but no signature.
-.PHONY: dist-gz
-dist-gz: $(_PROJECT)-$(_VERSION).tar.gz
-endif
-
-# Generate the tarball for the release.
-ifdef v
-__GIT_DIR = --git-dir=$(v)
-endif
-$(_PROJECT)-$(_VERSION).tar: $(foreach F,$(_EVERYTHING),$(v)$(F))
- @$(PRINTF_INFO) '\e[00;01;31mTAR\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
-ifndef _EVERYTHING
- $(Q)git archive --prefix=$(_PROJECT)-$(_VERSION)/ --format=tar $(__GIT_DIR) $(_VERSION) -o $@ #$Z
-endif
-ifdef _EVERYTHING
- $(Q)$(LN) -s . $(_PROJECT)-$(_VERSION)
- $(Q)$(TAR) c -- $(foreach F,$(_EVERYTHING),$(v)$(_PROJECT)-$(_VERSION)/$(F)) > $@
- $(Q)$(RM) $(_PROJECT)-$(_VERSION)
-endif
- @$(ECHO_EMPTY)
-
-# Compression rule for xz-compression. Used on the tarball.
-%.xz: %
- @$(PRINTF_INFO) '\e[00;01;31mXZ\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(XZ_COMPRESS) $< #$Z
- @$(ECHO_EMPTY)
-
-# Compression rule for bzip2-compression. Used on the tarball.
-%.bz2: %
- @$(PRINTF_INFO) '\e[00;01;31mBZIP2\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(BZIP2_COMPRESS) $< #$Z
- @$(ECHO_EMPTY)
-
-# Compression rule for gzip-compression. Used on the tarball.
-%.gz: %
- @$(PRINTF_INFO) '\e[00;01;31mGZIP\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(GZIP_COMPRESS) $< #$Z
- @$(ECHO_EMPTY)
-
-# Generate checksums of tarballs, compressed and uncompressed, and of their detached signatures.
-$(_PROJECT)-$(_VERSION).checksums: $(__DIST_FILES)
- @$(PRINTF_INFO) '\e[00;01;31mCHECKSUM\e[34m %s\e[00m\n' "$@"
- @$(PRINTF) '' > $@
-ifndef NO_BSD_SUM
- @if ! ($(ECHO) ':: sum -r ::' && sum -r $^ && $(ECHO)) >> $@ ; then $(PRINTF) '' > $@; fi
-endif
-ifndef NO_SYSV_SUM
- @if ! ($(ECHO) ':: sum -s ::' && sum -s $^ && $(ECHO)) >> $@ ; then $(PRINTF) '' > $@; fi
-endif
- @$(foreach C,$(DIST_CHECKSUMS),$(ECHO) ':: $(C) ::' >> $@ && $(C) $^ | $(GREP) -v '^--' >> $@ && $(ECHO) >> $@ &&) $(TRUE)
- @$(ECHO_EMPTY)
-
-# Signing rule. Used on the tarballs, compressed and uncompressed, and on the checksum file.
-%.sig: %
- @$(PRINTF_INFO) '\e[00;01;31mSIG\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(GPG) $(GPG_FLAGS) --local-user $(GPG_KEY) --detach-sign --armor --output $@ < $< #$Z
- @$(ECHO_EMPTY)
-
diff --git a/mk/empty.mk b/mk/empty.mk
deleted file mode 100644
index fd684f6..0000000
--- a/mk/empty.mk
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes empty rules that are filled by other files. ===#
-
-
-.PHONY: all
-all:
-
-.PHONY: everything
-everything:
-
-.PHONY: base
-base:
-
-.PHONY: cmd
-cmd:
-
-.PHONY: lib
-lib:
-
-.PHONY: doc
-doc:
-
-
-.PHONY: check
-check:
-
-
-.PHONY: install
-install:
-
-.PHONY: install-everything
-install-everything:
-
-.PHONY: install-base
-install-base:
-
-.PHONY: install-cmd
-install-cmd:
-
-.PHONY: install-lib
-install-lib:
-
-.PHONY: install-doc
-install-doc:
-
-
-.PHONY: installcheck
-installcheck:
-
-
-.PHONY: uninstall
-uninstall:
-
-
-
-.PHONY: all
-all: base
-
-.PHONY: everything
-everything: base
-
-.PHONY: base
-base: cmd lib
-
-
-.PHONY: install
-install: install-base
-
-.PHONY: install-everything
-install-everything: install-base
-
-.PHONY: install-base
-install-base: install-cmd install-lib
-
-
-
-.PHONY: install-strip
-install-strip: __STRIP = -s
-install-strip: install
-
-.PHONY: install-everything-strip
-install-everything-strip: __STRIP = -s
-install-everything-strip: install-everything
-
-.PHONY: install-base-strip
-install-base-strip: __STRIP = -s
-install-base-strip: install-base
-
-.PHONY: install-cmd-strip
-install-cmd-strip: __STRIP = -s
-install-cmd-strip: install-cmd
-
-.PHONY: install-lib-strip
-install-lib-strip: __STRIP = -s
-install-lib-strip: install-lib
-
diff --git a/mk/i18n.mk b/mk/i18n.mk
deleted file mode 100644
index ed6ec79..0000000
--- a/mk/i18n.mk
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for internationalisation. ===#
-
-
-# Enables the rules:
-# locale Build all translations.
-# update-po Update all .po files for further translation.
-# install-locale Install all locales.
-#
-# "All locales" are those listed in LOCALES.
-# If LOCALES is not defined, this file is ignored.
-#
-# If WITHOUT_GETTEXT is defined, `locale` and
-# `install-locale` will not do anything.
-#
-# _SRC should list all sources files, excluding the src/
-# at the beginning of the pathnames.
-
-
-ifdef LOCALES
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-all: locale
-everything: locale
-install: install-locale
-install-everything: install-locale
-uninstall: uninstall-locale
-
-
-# BUILD RULES:
-
-# Build all translations.
-ifdef WITHOUT_GETTEXT
-.PHONY: locale
-locale:
-endif
-ifndef WITHOUT_GETTEXT
-.PHONY: locale
-locale: $(foreach L,$(LOCALES),bin/mo/$(L)/messages.mo)
-endif
-
-# Update all translation files for further translation.
-.PHONY: update-po
-update-po: $(foreach L,$(LOCALES),po/$(L).po)
-
-# Generate template for translations.
-aux/$(_PROJECT).pot: $(foreach S,$(_SRC),$(v)src/$(S))
- @$(PRINTF_INFO) '\e[00;01;31mPOT\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(CPP) -DUSE_GETTEXT=1 $^ | \
- $(XGETTEXT) -o "$@" -Lc --from-code utf-8 --package-name "$(_PROJECT_FULL)" \
- --package-version $(_VERSION) --no-wrap --force-po \
- --copyright-holder '$(_COPYRIGHT_HOLDER)' - #$Z
- @$(ECHO_EMPTY)
-
-# Create or update a translation file.
-po/%.po: aux/$(_PROJECT).pot
- @$(PRINTF_INFO) '\e[00;01;31mPO\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p po
- $(Q)if ! $(TEST) -e $@; then \
- $(MSGINIT) --no-translator --no-wrap -i aux/$(_PROJECT).pot -o $@ -l $*; \
- else \
- $(MSGMERGE) --no-wrap -U $@ aux/$(_PROJECT).pot; \
- fi #$Z
- @$(TOUCH) $@
- @$(ECHO_EMPTY)
-
-# Compile a translation file.
-bin/mo/%/messages.mo: $(v)po/%.po
- @$(PRINTF_INFO) '\e[00;01;31mMO\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin/mo/$*
- $(Q)cd bin/mo/$* && $(MSGFMT) $(__back3unless_v)$< #$Z
- @$(ECHO_EMPTY)
-
-
-# INSTALL RULES:
-
-# Install all locales.
-ifdef WITHOUT_GETTEXT
-.PHONY: install-locale
-install-locale:
-endif
-ifndef WITHOUT_GETTEXT
-.PHONY: install-locale
-install-locale: $(foreach L,$(LOCALES),bin/mo/$(L)/messages.mo)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL) -dm755 -- $(foreach L,$(LOCALES),"$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES")
- $(Q)$(foreach L,$(LOCALES),$(INSTALL_DATA) bin/mo/$(L)/messages.mo -- "$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES/$(PKGNAME).mo" &&) $(TRUE)
- @$(ECHO_EMPTY)
-endif
-
-
-# UNINSTALL RULES:
-
-# Uninstall all locales.
-.PHONY: uninstall-locale
-uninstall-locale:
- -$(Q)$(RM) -- $(foreach L,$(LOCALES),"$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES/$(PKGNAME).mo")
-
-
-endif
-
diff --git a/mk/lang-c.mk b/mk/lang-c.mk
deleted file mode 100644
index 63015fb..0000000
--- a/mk/lang-c.mk
+++ /dev/null
@@ -1,307 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes rules for C programs. ===#
-
-
-# This file is ignored unless _C_STD is defined.
-# _C_STD should be set the the version of C that
-# is used.
-#
-# If you want to compile with -pedantic, define
-# the variable _PEDANTIC.
-#
-# Define _CPPFLAGS with any additional CPP
-# flags to use, _CFLAGS with any additional CC
-# flags to use, and _LDFLAGS with any additional
-# LD flags to use.
-#
-# Defined in path.mk, you can change _ALL_DIRS
-# if you do not want CPP definitions for all
-# directories.
-#
-# Define _HEADER_DIRLEVELS to specify the directory
-# nesting level in src. It is assumed that all
-# directories contain header files. Set to '0' if
-# there are no header files.
-#
-# _BIN shall list all commands to build. These
-# should be the basenames. For each command
-# you should be the variable _OBJ_$(COMMAND)
-# that lists all objects files (without the
-# suffix and without the aux/ prefix) that
-# are required to build the command.
-#
-# Binary you want installed to /sbin rather than
-# /bin shall be listed in _SBIN rather than in
-# _BIN. _SBIN and _BIN may not list binaries
-# with identical names. Analogically, you may
-# add _LIBEXEC for binary to be installed to
-# /libexec.
-#
-# If you only have one binary, you may select
-# to define _BINDIR to name the variable with
-# the pathname for the directory the binary
-# shall be installed. For example, if you want
-# the binary to be installed to /usr/sbin,
-# define _BINDIR = SBINDIR.
-#
-# List libraries to compile in in _LIB. For each
-# library, you should also define
-# _SO_VERSION_$(LIBRARY) and _SO_MAJOR_$(LIBRARY)
-# with the full version number and the major
-# version number, respectively. Additionally,
-# list all header files that shall be installed
-# in _H, these should not contain the 'src/' prefix
-# or the '.h' suffix.
-
-
-ifdef _C_STD
-
-
-
-# HELP VARIABLES:
-
-# Figure out whether the GCC is being used.
-ifeq ($(shell $(PRINTF) '%s\n' ${CC} | $(HEAD) -n 1),gcc)
-__USING_GCC = 1
-endif
-
-# Are there any commands?
-ifdef _BIN
-__HAVE_CMD_C = 1
-endif
-ifdef _SBIN
-__HAVE_CMD_C = 1
-endif
-ifdef _LIBEXEC
-__HAVE_CMD_C = 1
-endif
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-ifdef __HAVE_CMD_C
-cmd: cmd-c
-install-cmd: install-cmd-c
-uninstall: uninstall-cmd-c
-endif
-ifdef _LIB
-lib: lib-c
-install-lib: install-lib-c
-uninstall: uninstall-lib-c
-endif
-
-
-# BUILD VARIABLES:
-
-# Optimisation settings for C code compilation.
-ifndef OPTIMISE
-ifndef DEBUG
-OPTIMISE = -O2 -g
-endif
-ifdef DEBUG
-ifdef __USING_GCC
-OPTIMISE = -Og -g
-endif
-ifndef __USING_GCC
-OPTIMISE = -g
-endif
-endif
-endif
-
-# Warning settings for C code compilation.
-ifdef _PEDANTIC
-_PEDANTIC = -pedantic
-endif
-ifndef WARN
-ifndef DEBUG
-WARN = -Wall
-endif
-ifdef DEBUG
-ifdef __USING_GCC
-WARN = -Wall -Wextra $(_PEDANTIC) -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \
- -Wtrampolines -Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
- -Wno-variadic-macros -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align \
- -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wwrite-strings -Wlogical-op \
- -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance \
- -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn \
- -Wsuggest-attribute=format -Wnormalized=nfkc -fstrict-aliasing -fipa-pure-const -ftree-vrp \
- -fstack-usage -funsafe-loop-optimizations -Wshadow -Wredundant-decls -Winline -Wcast-qual \
- -Wsign-conversion -Wstrict-overflow=5 -Wconversion -Wsuggest-attribute=pure -Wswitch-default \
- -Wstrict-aliasing=1 -fstrict-overflow -Wfloat-equal -Wpadded -Waggregate-return \
- -Wtraditional-conversion
-endif
-ifndef __USING_GCC
-WARN = -Wall -Wextra $(_PEDANTIC)
-endif
-endif
-endif
-
-# Support for internationalisation?
-ifndef WITHOUT_GETTEXT
-_CPPFLAGS += -D'USE_GETTEXT=1'
-endif
-
-# Add CPP definitions for all directories.
-_CPPFLAGS += $(foreach D,$(_ALL_DIRS),-D'$(D)="$($(D))"')
-
-# Compilation and linking flags, and command.
-ifndef CPPFLAGS
-CPPFLAGS =
-endif
-ifndef CFLAGS
-CFLAGS = $(OPTIMISE) $(WARN)
-endif
-ifndef LDFLAGS
-LDFLAGS = $(OPTIMISE) $(WARN)
-endif
-__CC = $(CC) -std=$(_C_STD) -c $(_CPPFLAGS) $(_CFLAGS)
-__LD = $(CC) -std=$(_C_STD) $(_LDFLAGS)
-__CC_POST = $(CPPFLAGS) $(CFLAGS) $(EXTRA_CPPFLAGS) $(EXTRA_CFLAGS)
-__LD_POST = $(LDFLAGS) $(EXTRA_LDFLAGS)
-
-# Header files.
-__H =
-ifdef _HEADER_DIRLEVELS
-ifeq ($(_HEADER_DIRLEVELS),1)
-__H += src/*.h
-endif
-ifneq ($(_HEADER_DIRLEVELS),1)
-ifeq ($(_HEADER_DIRLEVELS),2)
-__H += src/*.h
-__H += src/*/*.h
-endif
-ifneq ($(_HEADER_DIRLEVELS),2)
-ifneq ($(_HEADER_DIRLEVELS),0)
-__H += $(foreach W,$(shell $(SEQ) $(_HEADER_DIRLEVELS) | while read n; do $(ECHO) $$($(SEQ) $$n)" " | $(SED) 's/[^ ]* /\/\*/g'; done | $(XARGS) $(ECHO)),src$(W).h)
-endif
-endif
-endif
-endif
-
-# Directory for the binary if there is only one binary.
-ifndef _BINDIR
-_BINDIR = BINDIR
-endif
-
-
-# BUILD RULES:
-
-.PHONY: cmd-c
-cmd-c: $(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),bin/$(B))
-
-.PHONY: lib-c
-lib-c: $(foreach B,$(_LIB),bin/$(B).so)
-
-# Compile a C file into an object file for a command.
-aux/%.o: $(v)src/%.c $(foreach H,$(__H),$(v)$(H))
- @$(PRINTF_INFO) '\e[00;01;31mCC\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell $(DIRNAME) $@)
- $(Q)$(__CC) -o $@ $< $(__CC_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Compile a C file into an object file for a library.
-aux/%.pic.o: $(v)src/%.c $(foreach H,$(__H),$(v)$(H))
- @$(PRINTF_INFO) '\e[00;01;31mCC\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell $(DIRNAME) $@)
- $(Q)$(__CC) -fPIC -o $@ $< $(__CC_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Link object files into a library.
-# Dependencies are declared below.
-bin/%.so:
- @$(PRINTF_INFO) '\e[00;01;31mLD\e[34m %s\e[00;32m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(__LD) -shared -Wl,-soname,$*.so.$(_SO_MAJOR_$*) -o $@ $^ $(__LD_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Link object files into a command.
-# Dependencies are declared below.
-bin/%:
- @$(PRINTF_INFO) '\e[00;01;31mLD\e[34m %s\e[00;32m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(__LD) -o $@ $^ $(__LD_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Dependencies for the rule above.
-include aux/lang-c.mk
-aux/lang-c.mk: Makefile
- @$(MKDIR) -p aux
- @$(ECHO) > aux/lang-c.mk
- @$(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),$(ECHO) bin/$(B): $(foreach O,$(_OBJ_$(B)),aux/$(O).o) >> aux/lang-c.mk &&) $(TRUE)
- @$(foreach B,$(_LIB),$(ECHO) bin/$(B).so: $(foreach O,$(_OBJ_$(B)),aux/$(O).pic.o) >> aux/lang-c.mk &&) $(TRUE)
-
-
-# INSTALL RULES:
-
-.PHONY: install-cmd-c
-install-cmd-c: $(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),bin/$(B))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
-ifndef COMMAND
-ifdef _BIN
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(BINDIR)"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_BIN),bin/$(B)) -- "$(DESTDIR)$(BINDIR)"
-endif
-ifdef _SBIN
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(SBINDIR)"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_SBIN),bin/$(B)) -- "$(DESTDIR)$(SBINDIR)"
-endif
-ifdef _LIBEXEC
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_LIBEXEC),bin/$(B)) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
-endif
-endif
-ifdef COMMAND
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$($(_BINDIR))"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $^ -- "$(DESTDIR)$($(_BINDIR))/$(COMMAND)"
-endif
- @$(ECHO_EMPTY)
-
-.PHONY: install-lib-c
-install-lib-c: $(foreach B,$(_LIB),bin/$(B).so)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LIBDIR)"
- $(Q)$(foreach B,$(_LIB),$(LN) -sf -- "$(B).so.$(_SO_VERSION_$(B))" "$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_MAJOR_$(B))" &&) $(TRUE)
- $(Q)$(foreach B,$(_LIB),$(INSTALL_PROGRAM) $(foreach B,$(_LIB),bin/$(B).so) -- "$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_VERSION_$(B))" &&) $(TRUE)
- $(Q)$(foreach B,$(_LIB),$(LN) -sf -- "$(B).so.$(_SO_VERSION_$(B))" "$(DESTDIR)$(LIBDIR)/$(B).so" &&) $(TRUE)
- $(Q)$(INSTALL_DIR) -- $(foreach H,$(_H),"$(DESTDIR)$(INCLUDEDIR)/$(shell $(DIRNAME) "$(H)")")
- $(Q)$(foreach H,$(_H),$(INSTALL_DATA) "src/$(H).h" -- "$(DESTDIR)$(INCLUDEDIR)/$(H).h" &&) $(TRUE)
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-.PHONY: uninstall-cmd-c
-uninstall-cmd-c:
-ifdef COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$($(_BINDIR))/$(COMMAND)"
-endif
-ifndef COMMAND
-ifdef _BIN
- -$(Q)$(RM) -- $(foreach B,$(_BIN),"$(DESTDIR)$(BINDIR)/$(B)")
-endif
-ifdef _SBIN
- -$(Q)$(RM) -- $(foreach B,$(_SBIN),"$(DESTDIR)$(SBINDIR)/$(B)")
-endif
-ifdef _LIBEXEC
- -$(Q)$(RM) -- $(foreach B,$(_LIBEXEC),"$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)/$(B)")
- -$(Q)$(RMDIR) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
-endif
-endif
-
-.PHONY: uninstall-lib-c
-uninstall-lib-c:
- -$(Q)$(RM) -- $(foreach B,$(_LIB),"$(DESTDIR)$(LIBDIR)/$(B).so")
- -$(Q)$(RM) -- $(foreach B,$(_LIB),"$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_MAJOR_$(B))")
- -$(Q)$(RM) -- $(foreach B,$(_LIB),"$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_VERSION_$(B))")
- -$(Q)$(RM) -- $(foreach H,$(_H),"$(DESTDIR)$(INCLUDEDIR)/$(H).h")
- -$(Q)$(foreach H,$(_H),if ! $(TEST) "$(shell $(ECHO) "$(H)" | $(CUT) -d / -f 1)" = "$(H)"; then $(RMDIR) -- "$(DESTDIR)$(INCLUDEDIR)/$(shell $(DIRNAME) "$(H)")"; fi;)
-
-endif
-
diff --git a/mk/lowerpath.mk b/mk/lowerpath.mk
deleted file mode 100644
index 77b3542..0000000
--- a/mk/lowerpath.mk
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file overrides values uppercase path variables with values lowercase path variables. ===#
-
-
-ifdef srcdir
-VPATH = $(srcdir)
-endif
-
-ifdef prefix
-PREFIX = $(prefix)
-endif
-
-ifdef sysconfdir
-SYSCONFDIR = $(sysconfdir)
-endif
-
-ifdef sharedstatedir
-COMDIR = $(sharedstatedir)
-endif
-
-ifdef localstatedir
-VARDIR = $(localstatedir)
-endif
-
-ifdef runstatedir
-RUNDIR = $(runstatedir)
-endif
-
-ifdef tmpdir
-TMPDIR = $(tmpdir)
-endif
-
-ifdef devdir
-DEVDIR = $(devdir)
-endif
-
-ifdef sysdir
-SYSDIR = $(sysdir)
-endif
-
-ifdef procdir
-PROCDIR = $(procdir)
-endif
-
-ifdef exec_prefix
-EXEC_PREFIX = $(exec_prefix)
-endif
-
-ifdef bindir
-BINDIR = $(bindir)
-endif
-
-ifdef sbindir
-SBINDIR = $(sbindir)
-endif
-
-ifdef libexecdir
-LIBEXECDIR = $(libexecdir)
-endif
-
-ifdef libdir
-LIBDIR = $(libdir)
-endif
-
-ifdef includedir
-INCLUDEDIR = $(includedir)
-endif
-
-ifdef oldincludedir
-OLDINCLUDEDIR = $(oldincludedir)
-endif
-
-ifdef datarootdir
-DATADIR = $(datarootdir)
-endif
-
-ifdef datadir
-RESDIR = $(datadir)
-endif
-
-ifdef libdatarootdir
-SYSDEPDATADIR = $(libdatarootdir)
-endif
-
-ifdef libdatadir
-SYSDEPRESDIR = $(libdatadir)
-endif
-
-ifdef lispdir
-LISPDIR = $(lispdir)
-endif
-
-ifdef localedir
-LOCALEDIR = $(localedir)
-endif
-
-ifdef licensedir
-LICENSEDIR = $(licensedir)
-endif
-
-ifdef cachedir
-CACHEDIR = $(cachedir)
-endif
-
-ifdef spooldir
-SPOOLDIR = $(spooldir)
-endif
-
-ifdef emptydir
-EMPTYDIR = $(emptydir)
-endif
-
-ifdef logdir
-LOGDIR = $(logdir)
-endif
-
-ifdef statedir
-STATEDIR = $(statedir)
-endif
-
-ifdef gamedir
-GAMEDIR = $(gamedir)
-endif
-
-ifdef sharedcachedir
-COMCACHEDIR = $(sharedcachedir)
-endif
-
-ifdef sharedpooldir
-COMPOOLDIR = $(sharedpooldir)
-endif
-
-ifdef sharedlogdir
-COMLOGDIR = $(sharedlogdir)
-endif
-
-ifdef sharedlogdir
-COMSTATEDIR = $(sharedstatedir)
-endif
-
-ifdef sharedgamedir
-COMGAMEDIR = $(sharedgamedir)
-endif
-
-ifdef localtmpdir
-VARTMPDIR = $(localtmpdir)
-endif
-
-ifdef sharedtmpdir
-COMTMPDIR = $(sharedtmpdir)
-endif
-
-ifdef lockdir
-LOCKDIR = $(lockdir)
-endif
-
-ifdef skeldir
-SKELDIR = $(skeldir)
-endif
-
-ifdef selfprocdir
-SELFPROCDIR = $(selfprocdir)
-endif
-
-ifdef docdir
-DOCDIR = $(docdir)
-endif
-
-ifdef infodir
-INFODIR = $(infodir)
-endif
-
-ifdef dvidir
-DVIDIR = $(dvidir)
-endif
-
-ifdef pdfdir
-PDFDIR = $(pdfdir)
-endif
-
-ifdef psdir
-PSDIR = $(psdir)
-endif
-
-ifdef htmldir
-HTMLDIR = $(htmldir)
-endif
-
-ifdef mandir
-MANDIR = $(mandir)
-endif
-
-ifdef man0
-MAN0 = $(man0)
-endif
-
-ifdef man1
-MAN1 = $(man1)
-endif
-
-ifdef man2
-MAN2 = $(man2)
-endif
-
-ifdef man3
-MAN3 = $(man3)
-endif
-
-ifdef man4
-MAN4 = $(man4)
-endif
-
-ifdef man5
-MAN5 = $(man5)
-endif
-
-ifdef man6
-MAN6 = $(man6)
-endif
-
-ifdef man7
-MAN7 = $(man7)
-endif
-
-ifdef man8
-MAN8 = $(man8)
-endif
-
-ifdef man9
-MAN9 = $(man9)
-endif
-
-ifdef man0ext
-MAN0EXT = $(man0ext)
-endif
-
-ifdef man1ext
-MAN1EXT = $(man1ext)
-endif
-
-ifdef man2ext
-MAN2EXT = $(man2ext)
-endif
-
-ifdef man3ext
-MAN3EXT = $(man3ext)
-endif
-
-ifdef man4ext
-MAN4EXT = $(man4ext)
-endif
-
-ifdef man5ext
-MAN5EXT = $(man5ext)
-endif
-
-ifdef man6ext
-MAN6EXT = $(man6ext)
-endif
-
-ifdef man7ext
-MAN7EXT = $(man7ext)
-endif
-
-ifdef man8ext
-MAN8EXT = $(man8ext)
-endif
-
-ifdef man9ext
-MAN9EXT = $(man9ext)
-endif
-
diff --git a/mk/man.mk b/mk/man.mk
deleted file mode 100644
index 0cd7ca9..0000000
--- a/mk/man.mk
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for man pages. ===#
-
-
-# Enables the rules:
-# install-man Install all man page
-# install-man-untranslated Install untranslated man page
-# install-man-locale Install translated man page
-#
-# This file is ignored unless _MAN_PAGE_SECTIONS
-# is defined. _MAN_PAGE_SECTIONS should list all
-# used man page sections. For all used sections
-# there should also be a variable named
-# _MAN_$(SECTION) that lists the suffixless
-# basename of all man pages in that section.
-#
-# The pathname of a man page should look
-# like this: doc/man/$(DOCUMENT).$(SECTION)
-# Translations looks like this:
-# doc/man/$(DOCUMENT).$(LANGUAGE).$(SECTION)
-#
-# For each language and section, there should
-# be a variable _MAN_$(LANGUAGE)_$(SECTION)
-# that lists all translated documents in that
-# section and for that lanuage. These should
-# be suffixless basenames. The lanuage counts
-# as a suffix.
-#
-# The translations of the man pages to
-# install should be specified, by language,
-# in the variable MAN_LOCALES.
-
-
-ifdef _MAN_PAGE_SECTIONS
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-install: install-man
-install-everything: install-man
-install-doc: install-man
-uninstall: uninstall-man
-
-
-# HELP VARIABLES
-
-# Customisable man page filename.
-ifdef COMMAND
-ifeq ($(shell $(PRINTF) '%s\n' $(COMMAND) | $(WC) -l),1)
-ifeq ($(shell $(PRINTF) '%s\n' $(_MAN_PAGE_SECTIONS) | $(WC) -l),1)
-ifeq ($(shell $(PRINTF) '%s\n' $(_MAN_$(_MAN_PAGE_SECTIONS)) | $(WC) -l),1)
-__MAN_COMMAND = $(COMMAND)$(MAN$(_MAN_PAGE_SECTIONS)EXT)
-endif
-endif
-endif
-endif
-
-
-# INSTALL RULES:
-
-.PHONY: install-man
-install-man: install-man-untranslated install-man-locale
-
-.PHONY: install-man-untranslated
-install-man-untranslated:
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- $(foreach S,$(_MAN_PAGE_SECTIONS),"$(DESTDIR)$(MANDIR)/$(MAN$(S))")
-ifndef __MAN_COMMAND
- $(Q)$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(S) -- "$(DESTDIR)$(MANDIR)/$(MAN$(S))/$(P)$(MAN$(S)EXT)" &&)) $(TRUE)
-endif
-ifdef __MAN_COMMAND
- $(Q)$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(S) -- "$(DESTDIR)$(MANDIR)/$(MAN$(S))/$(__MAN_COMMAND)" &&)) $(TRUE)
-endif
- @$(ECHO_EMPTY)
-
-.PHONY: install-man-locale
-install-man-locale:
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(foreach L,$(MAN_LOCALES),$(INSTALL_DIR) -- $(foreach S,$(_MAN_PAGE_SECTIONS),"$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))") &&) $(TRUE)
-ifndef __MAN_COMMAND
- $(Q)$(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(L).$(S) -- "$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(P)$(MAN$(S)EXT)" &&))) $(TRUE)
-endif
-ifdef __MAN_COMMAND
- $(Q)$(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(L).$(S) -- "$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(__MAN_COMMAND)" &&))) $(TRUE)
-endif
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-.PHONY: uninstall-man
-uninstall-man:
-ifndef __MAN_COMMAND
- -$(Q)$(RM) -- $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),"$(DESTDIR)$(MANDIR)/$(MAN$(S))/$(P)$(MAN$(S)EXT)"))
- -$(Q)$(RM) -- $(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),"$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(P)$(MAN$(S)EXT)")))
-endif
-ifdef __MAN_COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$(MANDIR)/$(MAN$(_MAN_PAGE_SECTIONS))/$(__MAN_COMMAND)"
- -$(Q)$(RM) -- $(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),"$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(__MAN_COMMAND)")))
-endif
-
-
-endif
-
diff --git a/mk/path.mk b/mk/path.mk
deleted file mode 100644
index 9d9d855..0000000
--- a/mk/path.mk
+++ /dev/null
@@ -1,176 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file define path variables. ===#
-
-
-ifndef __PATH_MK_INCLUDED
-__PATH_MK_INCLUDED = 1
-
-
-# DIRECTORIES:
-
-# The package path prefix, if you want to install to another root, set DESTDIR to that root.
-PREFIX = /usr
-# The package path prefix for /bin, /sbin, /lib and /libexec.
-EXEC_PREFIX = /usr
-# The command path excluding prefix.
-BIN = /bin
-# The administration command path excluding prefix.
-SBIN = /sbin
-# The library path excluding prefix.
-LIB = /lib
-# The executable library path excluding prefix.
-LIBEXEC = /libexec
-# The header-file path excluding prefix.
-INCLUDE = /include
-# The resource path excluding prefix.
-DATA = /share
-# The man page sections path excluding prefix.
-MAN0 = /man0
-MAN1 = /man1
-MAN2 = /man2
-MAN3 = /man3
-MAN4 = /man4
-MAN5 = /man5
-MAN6 = /man6
-MAN7 = /man7
-MAN8 = /man8
-MAN9 = /man9
-
-# The command path including prefix.
-BINDIR = $(EXEC_PREFIX)$(BIN)
-# The administration command path including prefix.
-SBINDIR = $(EXEC_PREFIX)$(SBIN)
-# The library path including prefix.
-LIBDIR = $(EXEC_PREFIX)$(LIB)
-# The executable library path including prefix.
-LIBEXECDIR = $(EXEC_PREFIX)$(LIBEXEC)
-# The header-file path including prefix.
-INCLUDEDIR = $(PREFIX)$(INCLUDE)
-# The header-file path including prefix. Must not be /usr/local.
-ifeq ($(PREFIX),/usr/lcoal)
-OLDINCLUDEDIR = /usr$(INCLUDE)
-endif
-ifneq ($(PREFIX),/usr/lcoal)
-OLDINCLUDEDIR = $(PREFIX)$(INCLUDE)
-endif
-# The data path including prefix.
-DATADIR = $(PREFIX)$(DATA)
-# The architecture-dependent data path including prefix.
-SYSDEPDATADIR = $(DATADIR)
-# The resource path including prefix.
-RESDIR = $(DATADIR)
-# The architecture-dependent resource path including prefix.
-SYSDEPRESDIR = $(RESDIR)
-# The generic documentation path including prefix.
-DOCDIR = $(DATADIR)/doc/$(PKGNAME)
-# The info manual documentation path including prefix.
-INFODIR = $(DATADIR)/info
-# The DVI documentation path including prefix.
-DVIDIR = $(DOCDIR)
-# The PDF documentation path including prefix.
-PDFDIR = $(DOCDIR)
-# The PostScript documentation path including prefix.
-PSDIR = $(DOCDIR)
-# The HTML documentation path including prefix.
-HTMLDIR = $(DOCDIR)
-# The man page documentation path including prefix.
-MANDIR = $(DATADIR)/man
-# The Emacs LISP path including prefix.
-LISPDIR = $(DATADIR)/emacs/site-lisp
-# The locale path including prefix.
-LOCALEDIR = $(DATADIR)/locale
-# The license base path including prefix.
-LICENSEDIR = $(DATADIR)/licenses
-# The persistent variable data directory.
-VARDIR = /var
-# The persistent directory for temporary files.
-VARTMPDIR = $(VARDIR)/tmp
-# The network-common persistent variable data directory.
-COMDIR = /com
-# The network-common persistent directory for temporary files.
-COMTMPDIR = $(COMDIR)/tmp
-# The transient directory for temporary files.
-TMPDIR = /tmp
-# The transient directory for runtime files.
-RUNDIR = /run
-# The directory for site-specific configurations.
-SYSCONFDIR = /etc
-# The directory for pseudo-devices.
-DEVDIR = /dev
-# The /sys directory.
-SYSDIR = /sys
-# The /proc directory
-PROCDIR = /proc
-# The /proc/self directory
-SELFPROCDIR = $(PROCDIR)/self
-# The cache directory.
-CACHEDIR = $(VARDIR)/cache
-# The spool directory.
-SPOOLDIR = $(VARDIR)/spool
-# The empty directory.
-EMPTYDIR = $(VARDIR)/empty
-# The logfile directory.
-LOGDIR = $(VARDIR)/log
-# The state directory.
-STATEDIR = $(VARDIR)/lib
-# The highscore directory.
-GAMEDIR = $(VARDIR)/games
-# The lockfile directory.
-LOCKDIR = $(RUNDIR)/lock
-# The user skeleton directory.
-SKELDIR = $(SYSCONFDIR)/skel
-# The network-common cache directory.
-COMCACHEDIR = $(COMDIR)/cache
-# The network-common spool directory.
-COMSPOOLDIR = $(COMDIR)/spool
-# The network-common logfile directory.
-COMLOGDIR = $(COMDIR)/log
-# The network-common state directory.
-COMSTATEDIR = $(COMDIR)/lib
-# The network-common highscore directory.
-COMGAMEDIR = $(COMDIR)/games
-
-
-# FILENAME SUFFIXES:
-
-# Filename suffixes for man pages by section.
-MAN0EXT = .0
-MAN1EXT = .1
-MAN2EXT = .2
-MAN3EXT = .3
-MAN4EXT = .4
-MAN5EXT = .5
-MAN6EXT = .6
-MAN7EXT = .7
-MAN8EXT = .8
-MAN9EXT = .9
-
-
-# HELP VARIABLES:
-
-# All path variables that includes the prefix,
-# or are unaffected by the prefix.
-_ALL_DIRS = BINDIR SBINDIR LIBDIR LIBEXECDIR INCLUDEDIR DATADIR SYSDEPDATADIR DOCDIR \
- INFODIR DVIDIR PDFDIR PSDIR HTMLDIR MANDIR LOCALEDIR LICENSEDIR VARDIR \
- RESDIR VARTMPDIR COMDIR COMTMPDIR TMPDIR RUNDIR SYSCONFDIR DEVDIR SYSDIR \
- PROCDIR SELFPROCDIR CACHEDIR SPOOLDIR EMPTYDIR LOGDIR STATEDIR GAMEDIR \
- LOCKDIR SKELDIR COMCACHEDIR COMSPOOLDIR COMLOGDIR COMSTATEDIR COMGAMEDIR \
- SYSDEPRESDIR OLDINCLUDEDIR
-
-# ../, ../../, and ../../../, ignored if v is used, which if an absolute path.
-ifndef v
-__back1unless_v = ../
-__back2unless_v = ../../
-__back3unless_v = ../../../
-endif
-
-
-endif
-
diff --git a/mk/prologue.mk b/mk/prologue.mk
deleted file mode 100644
index 5d9a558..0000000
--- a/mk/prologue.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes rules for automatically rebuilding the makefile. ===#
-
-
-base: Makefile
-
-Makefile: $(v)Makefile.in config.status $(v)configure $(v)mk/configure
- ./config.status
-
diff --git a/mk/shell.mk b/mk/shell.mk
deleted file mode 100644
index 2747152..0000000
--- a/mk/shell.mk
+++ /dev/null
@@ -1,233 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for shell tab-completion using auto-auto-complete. ===#
-
-
-# Enables the rules:
-# shell Build tab-completion for all supported shells
-# bash Build GNU Bash tab-completion
-# fish Build fish tab-completion
-# zhs Build Z shell tab-completion
-# install-shell Install tab-completion for all supported shells
-# install-bash Install GNU Bash tab-completion
-# install-fish Install fish tab-completion
-# install-zsh Install Z shell tab-completion
-#
-# This file is ignored unless
-# _AUTO_COMPLETE is defined.
-#
-# _AUTO_COMPLETE shall list all commands that
-# have an auto-auto-complete. These should be
-# named src/$(COMMAND).auto-completion, where
-# $(COMMAND) is the command with the script.
-# If all auto-auto-complete scripts translations
-# named src/$(COMMAND).$(LOCALE).auto-completion,
-# SHELL_LOCALE can be set to install exactly
-# on translation in place of the non-translated
-# versions.
-#
-# Although not used by this file, you should
-# define _SHELL_LOCALES that lists all available
-# translations. (it is used by dist.mk.)
-#
-# You should also define _WITH_SHELL if you
-# want shell tab-completion unless the user
-# specifies otherwise. If you want it for
-# just some shells, define _WITH_$(SHELL)
-# for those shells instead of _WITH_SHELL.
-
-
-ifdef _AUTO_COMPLETE
-
-
-# HELP VARIABLES:
-
-# Include all that were not explicitly excluded?
-ifdef _WITH_SHELL
-_WITH_BASH = 1
-_WITH_FISH = 1
-_WITH_ZSH = 1
-endif
-
-# Include for GNU Bash?
-ifdef WITH_BASH
-__WITH_BASH = 1
-endif
-ifndef WITH_BASH
-ifndef WITHOUT_BASH
-ifdef _WITH_BASH
-__WITH_BASH = 1
-endif
-endif
-endif
-
-# Include for fish?
-ifdef WITH_FISH
-__WITH_FISH = 1
-endif
-ifndef WITH_FISH
-ifndef WITHOUT_FISH
-ifdef _WITH_FISH
-__WITH_FISH = 1
-endif
-endif
-endif
-
-# Include for Z Shell?
-ifdef WITH_ZSH
-__WITH_ZSH = 1
-endif
-ifndef WITH_ZSH
-ifndef WITHOUT_ZSH
-ifdef _WITH_ZSH
-__WITH_ZSH = 1
-endif
-endif
-endif
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-all: shell
-everything: shell
-install: install-shell
-install-doc: install-info install-dvi install-pdf install-ps install-html
-uninstall: uninstall-shell
-
-shell:
-install-shell:
-
-ifdef __WITH_BASH
-shell: bash
-install-shell: install-bash
-endif
-ifdef __WITH_FISH
-shell: fish
-install-shell: install-fish
-endif
-ifdef __WITH_ZSH
-shell: zsh
-install-shell: install-zsh
-endif
-
-
-# HELP VARIABLES:
-
-# Affixes on the source files.
-ifdef SHELL_LOCALE
-__AAC_L = .$(SHELL_LOCALE)
-endif
-__AAC = $(__AAC_L).auto-completion
-
-# Customised command name.
-ifdef COMMAND
-ifeq ($(shell $(PRINTF) '%s\n' $(COMMAND) | $(WC) -l),1)
-ifeq ($(shell $(PRINTF) '%s\n' $(_AUTO_COMPLETE) | $(WC) -l),1)
-__SHELL_COMMAND = "command=$(COMMAND)"
-endif
-endif
-endif
-
-
-# BUILD RULES:
-
-# Built tab-completion scripts for GNU Bash.
-.PHONY: bash
-bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion)
-
-# Built tab-completion scripts for fish.
-.PHONY: fish
-fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion)
-
-# Built tab-completion scripts for Z shell.
-.PHONY: zsh
-zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion)
-
-# Built a tab-completion script for GNU Bash.
-bin/%.bash-completion: $(v)src/%$(__AAC)
- @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(AUTO_AUTO_COMPLETE) bash -o $@ -s $< $(__SHELL_COMMAND) #$Z
- @$(ECHO_EMPTY)
-
-# Built a tab-completion script for fish.
-bin/%.fish-completion: $(v)src/%$(__AAC)
- @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(AUTO_AUTO_COMPLETE) fish -o $@ -s $< $(__SHELL_COMMAND) #$Z
- @$(ECHO_EMPTY)
-
-# Built a tab-completion script for Z shell.
-bin/%.zsh-completion: $(v)src/%$(__AAC)
- @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(AUTO_AUTO_COMPLETE) zsh -o $@ -s $< $(__SHELL_COMMAND) #$Z
- @$(ECHO_EMPTY)
-
-
-# INSTALL RULES:
-
-# Install tab-completion scripts for GNU Bash.
-.PHONY: install-bash
-install-bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions"
-ifndef __SHELL_COMMAND
- $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).bash-completion -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)" &&) $(TRUE)
-endif
-ifdef __SHELL_COMMAND
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
-endif
- @$(ECHO_EMPTY)
-
-# Install tab-completion scripts for fish.
-.PHONY: install-fish
-install-fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/fish/completions"
-ifndef __SHELL_COMMAND
- $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).fish-completion -- "$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish" &&) $(TRUE)
-endif
-ifdef __SHELL_COMMAND
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
-endif
- @$(ECHO_EMPTY)
-
-# Install tab-completion scripts for Z shell.
-.PHONY: install-zsh
-install-zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions"
-ifndef __SHELL_COMMAND
- $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).zsh-completion -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)" &&) $(TRUE)
-endif
-ifdef __SHELL_COMMAND
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
-endif
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-# Uninstall tab-completion.
-.PHONY: uninstall-shell
-uninstall-shell:
-ifndef __SHELL_COMMAND
- -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)")
- -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish")
- -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)")
-endif
-ifdef __SHELL_COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
- -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
- -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
-endif
-
-
-endif
-
diff --git a/mk/tags.mk b/mk/tags.mk
deleted file mode 100644
index 926cb5d..0000000
--- a/mk/tags.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for generate etags- and ctags-tablse. ===#
-
-
-# Generate etags-table.
-.PHONY: TAGS
-TAGS:
- @$(ECHO)
- @$(ECHO) "TAGS is not implemented. Did not see the need. Feel free to implement if you want."
- @$(ECHO)
-
-# Generate ctags-table
-.PHONY: tags
-tags:
- @$(ECHO)
- @$(ECHO) "tags is not implemented. Did not see the need. Feel free to implement if you want."
- @$(ECHO)
-
diff --git a/mk/texinfo.mk b/mk/texinfo.mk
deleted file mode 100644
index e2ccb12..0000000
--- a/mk/texinfo.mk
+++ /dev/null
@@ -1,294 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# TODO ((support translations))
-#=== These rules are used for Texinfo manuals. ===#
-
-
-# Enables the rules:
-# info Build info manual
-# dvi Build DVI manual
-# pdf Build PDF manual
-# ps Build PostScript manual
-# html Build HTML manual
-# install-info Install info manual
-# install-dvi Install DVI manual
-# install-pdf Install PDF manual
-# install-ps Install PostScript manual
-# install-html Install HTML manual
-#
-# This file is ignored unless
-# _HAVE_TEXINFO_MANUAL is defined.
-#
-# This file can only build output for
-# one Texinfo manual. This manual must
-# be named doc/info/$(_PROJECT).texinfo.
-# Additional sourced are set by specifing
-# how man directories deep doc/info nests
-# in the variable _TEXINFO_DIRLEVELS.
-#
-# If the info manual splits, specify the
-# split-number, of the file with the highest
-# split-number, in the variable _INFOPARTS.
-#
-# If the project has a logo, _LOGO should
-# name the suffixless basename of the SVG
-# files that contains the logo. This file
-# must be located in doc/.
-#
-# _HTML_FILES should the basename (with
-# suffix) of all files generated by `html`.
-#
-# The user may define TEXINFO_FLAGS that
-# adds additional flags when compiling
-# DVI, PDF, and PostScript manuals. The
-# user may also define INFO_FLAGS that
-# adds additional flags when compiling
-# info and HTML manuals.
-
-
-ifdef _HAVE_TEXINFO_MANUAL
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-all: info
-everything: info dvi pdf ps html
-doc: info dvi pdf ps html
-install: install-info
-install-everything: install-info install-dvi install-pdf install-ps install-html
-install-doc: install-info install-dvi install-pdf install-ps install-html
-uninstall: uninstall-info uninstall-dvi uninstall-pdf uninstall-ps uninstall-html
-
-
-# HELP VARIABLES:
-
-# Files from which the Texinfo manuals are built.
-ifdef _TEXINFO_DIRLEVELS
-ifeq ($(_TEXINFO_DIRLEVELS),1)
-__TEXI_SRC_ = *.texinfo
-endif
-ifeq ($(_TEXINFO_DIRLEVELS),2)
-__TEXI_SRC_ = *.texinfo */*.texinfo
-endif
-ifeq ($(_TEXINFO_DIRLEVELS),3)
-__TEXI_SRC_ = *.texinfo */*.texinfo */*/*.texinfo
-endif
-ifneq ($(_TEXINFO_DIRLEVELS),1)
-ifneq ($(_TEXINFO_DIRLEVELS),2)
-ifneq ($(_TEXINFO_DIRLEVELS),3)
-__TEXI_SRC_ = $(foreach W,$(shell $(SEQ) $(_TEXINFO_DIRLEVELS) | while read n; do $(ECHO) $$($(SEQ) $$n)" " | $(SED) 's/[^ ]* /\/\*/g'; done | $(XARGS) $(ECHO)),$(shell $(ECHO) $(W).texinfo | $(SED) 's/^.//'))
-endif
-endif
-endif
-__TEXI_SRC = $(foreach S,$(__TEXI_SRC_),$(foreach F,$(shell cd $(v)doc/info && $(ECHO) $(S)),aux/doc/$(F)))
-endif
-
-# Split parts of the info manual.
-ifdef _INFOPARTS
-ifneq ($(_INFOPARTS),0)
-__INFOPARTS = $(shell $(SEQ))
-endif
-endif
-
-# Flags for TeX processed output.
-__TEXINFO_FLAGS = $(TEXINFO_FLAGS)
-ifdef _LOGO
-__TEXINFO_FLAGS += '--texinfo="@set LOGO $(_LOGO)"'
-endif
-
-
-# BUILD RULES:
-
-ifdef _LOGO
-# Prepare conversion of logo.
-aux/$(_LOGO).svg: $(v)doc/$(_LOGO).svg
- @$(PRINTF_INFO) '\e[00;01;31mCP\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(CP) $^ $@ #$Z
- @$(ECHO_EMPTY)
-
-# Intermediate format for the logo for DVI and PostScript manuals.
-aux/$(_LOGO).ps: $(v)doc/$(_LOGO).svg
- @$(PRINTF_INFO) '\e[00;01;31mPS\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(SVG2PS) $^ > $@ #$Z
- @$(ECHO_EMPTY)
-
-# Logo for DVI and PostScript manuals.
-aux/$(_LOGO).eps: aux/$(_LOGO).ps
- @$(PRINTF_INFO) '\e[00;01;31mEPS\e[34m %s\e[00m$A\n' "$@"
- $(Q)$(PS2EPS) $^ #$Z
- @$(ECHO_EMPTY)
-
-# Logo for PDF manual.
-aux/$(_LOGO).pdf: $(v)doc/$(_LOGO).svg
- @$(PRINTF_INFO) '\e[00;01;31mPDF\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(SVG2PDF) $^ > $@ #$Z
- @$(ECHO_EMPTY)
-endif
-
-# Copy texinfo files to aux/doc.
-aux/doc/%.texinfo: $(v)doc/info/%.texinfo
- @$(PRINTF_INFO) '\e[00;01;31mCP\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell $(DIRNAME) $@)
- $(Q)$(CP) $< $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build info manual.
-.PHONY: info
-info: $(__TEXI_SRC) bin/$(_PROJECT).info
-bin/%.info $(foreach P,$(__INFOPARTS),bin/%.info-$(P)): aux/doc/%.texinfo $(__TEXI_SRC)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(MAKEINFO) $(INFO_FLAGS) $< #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) $*.info $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build DVI manual.
-.PHONY: dvi
-dvi: $(__TEXI_SRC) bin/$(_PROJECT).dvi
-bin/%.dvi: aux/doc/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).eps)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d aux/dvi/$* || $(RM) -rf aux/dvi/$*
- @$(MKDIR) -p aux/dvi/$* bin
- $(Q)cd aux/dvi/$* && $(TEXI2DVI) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) aux/dvi/$*/$*.dvi $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build PDF manual.
-.PHONY: pdf
-pdf: $(__TEXI_SRC) bin/$(_PROJECT).pdf
-bin/%.pdf: aux/doc/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).pdf)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d aux/pdf/$* || $(RM) -rf aux/pdf/$*
- @$(MKDIR) -p aux/pdf/$* bin
- $(Q)cd aux/pdf/$* && $(TEXI2PDF) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) aux/pdf/$*/$*.pdf $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build PostScript manual.
-.PHONY: ps
-ps: $(__TEXI_SRC) bin/$(_PROJECT).ps
-bin/%.ps: aux/doc/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).eps)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d aux/ps/$* || $(RM) -rf aux/ps/$*
- @$(MKDIR) -p aux/ps/$* bin
- $(Q)cd aux/ps/$* && $(TEXI2PS) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) aux/ps/$*/$*.ps $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build HTML manual.
-.PHONY: html
-html: $(__TEXI_SRC) bin/html/$(_PROJECT)/index.html
-bin/html/%/index.html: aux/doc/%.texinfo $(__TEXI_SRC)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d bin/html/$* || $(RM) -rf bin/html/$*
- @$(MKDIR) -p bin/html
- $(Q)cd bin/html && $(MAKEINFO_HTML) $(INFO_FLAGS) $(__back2unless_v)$< < /dev/null #$Z
- @$(ECHO_EMPTY)
-
-
-# INSTALL RULES:
-
-# Install info manual.
-.PHONY: install-info
-install-info: bin/$(_PROJECT).info $(foreach P,$(__INFOPARTS),bin/%.info-$(P))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(INFODIR)"
- $(Q)$(INSTALL_DATA) bin/$(_PROJECT).info -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
- $(Q)$(forearch P,$(__INFOPARTS),$(INSTALL_DATA) bin/$*.info-$(P) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)" &&) $(TRUE)
-ifdef POST_INSTALL
- $(POST_INSTALL)
-endif
- $(Q)if $(SHELL) -c '$(N) $(INSTALL_INFO) --version' > /dev/null 2>&1; then \
- $(N)$(z) $(INSTALL_INFO) -- "${DESTDIR}${INFODIR}/$(PKGNAME).info" "${DESTDIR}${INFODIR}/dir"; \
- else \
- $(TRUE); \
- fi
-ifdef POST_INSTALL
- $(NORMAL_INSTALL)
-endif
- @$(ECHO_EMPTY)
-
-# Install DVI manual.
-.PHONY: install-dvi
-install-dvi: bin/$(_PROJECT).dvi
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DVIDIR)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DVIDIR)/$(PKGNAME).dvi"
- @$(ECHO_EMPTY)
-
-# Install PDF manual.
-.PHONY: install-pdf
-install-pdf: bin/$(_PROJECT).pdf
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(PDFDIR)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(PDFDIR)/$(PKGNAME).pdf"
- @$(ECHO_EMPTY)
-
-# Install PostScript manual.
-.PHONY: install-ps
-install-ps: bin/$(_PROJECT).ps
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(PSDIR)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(PSDIR)/$(PKGNAME).ps"
- @$(ECHO_EMPTY)
-
-# Install HTML manual.
-.PHONY: install-html
-install-html: $(foreach F,$(_HTML_FILES),bin/html/$(_PROJECT)/$(F))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/"
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-# Uninstall info manual.
-.PHONY: uninstall-info
-uninstall-info:
-ifdef PRE_UNINSTALL
- $(PRE_UNINSTALL)
-endif
- -$(Q)$(N)$(a) $(INSTALL_INFO) --delete -- "${DESTDIR}${INFODIR}/$(PKGNAME).info" "${DESTDIR}${INFODIR}/dir"
-ifdef PRE_UNINSTALL
- $(NORMAL_UNINSTALL)
-endif
- -$(Q)$(RM) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info" $(forearch P,$(__INFOPARTS),"$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)")
-
-# Uninstall DVI manual.
-.PHONY: uninstall-dvi
-uninstall-dvi:
- -$(Q)$(RM) -- "$(DESTDIR)$(DVIDIR)/$(PKGNAME).dvi"
-
-# Uninstall PDF manual.
-.PHONY: uninstall-pdf
-uninstall-pdf:
- -$(Q)$(RM) -- "$(DESTDIR)$(PDFDIR)/$(PKGNAME).pdf"
-
-# Uninstall PostScript manual.
-.PHONY: uninstall-ps
-uninstall-ps:
- -$(Q)$(RM) -- "$(DESTDIR)$(PSDIR)/$(PKGNAME).ps"
-
-# Uninstall HTML manual.
-.PHONY: uninstall-html
-uninstall-html:
- -$(Q)$(RM) -- $(foreach F,$(_HTML_FILES),"$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/$(F)")
- -$(Q)$(RM) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)"
-
-
-endif
-
diff --git a/mk/tools.mk b/mk/tools.mk
deleted file mode 100644
index e3d9bfe..0000000
--- a/mk/tools.mk
+++ /dev/null
@@ -1,163 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file defines variables for all used commands. ===#
-
-
-# Part of GNU Coreutils:
-BASENAME ?= basename
-CHGRP ?= chgrp
-CHMOD ?= chmod
-CHOWN ?= chown
-CP ?= cp
-CPLIT ?= cplit
-CUT ?= cut
-DATE ?= date
-DIRNAME ?= dirname
-ECHO ?= echo
-ENV ?= env
-EXPAND ?= expand
-EXPR ?= expr
-FALS ?= false
-FMT ?= fmt
-FOLD ?= fold
-HEAD ?= head
-INSTALL ?= install
-INSTALL_DATA ?= $(INSTALL) -m644
-INSTALL_DIR ?= $(INSTALL) -dm755
-INSTALL_PROGRAM ?= $(INSTALL) -m755
-JOIN ?= join
-LN ?= ln
-MKDIR ?= mkdir
-MKFIFO ?= mkfifo
-MKNOD ?= mknod
-MV ?= mv
-NL ?= nl
-NPROC ?= nproc
-NUMFMT ?= numfmt
-OD ?= od
-PASTE ?= paste
-PATHCHK ?= pathchk
-PR ?= pr
-PRINTF ?= printf
-READLINK ?= readlink
-REALPATH ?= realpath
-RM ?= rm
-RMDIR ?= rmdir
-SEQ ?= seq
-SLEEP ?= sleep
-SORT ?= sort
-SPLIT ?= split
-STAT ?= stat
-TAC ?= tac
-TAIL ?= tail
-TEE ?= tee
-TEST ?= test
-TOUCH ?= touch
-TR ?= tr
-TRUE ?= true
-TRUNCATE ?= truncate
-TSORT ?= tsort
-UNAME ?= uname
-UNEXPAND ?= unexpand
-UNIQ ?= uniq
-WC ?= wc
-YES ?= yes
-
-# Part of GNU help2man:
-HELP2MAN ?= help2man
-
-# Part of GNU tar:
-TAR ?= tar
-
-# Part of GNU Findutils:
-FIND ?= find
-XARGS ?= xargs
-
-# Part of GNU Grep:
-GREP ?= grep
-EGREP ?= egrep
-FGREP ?= fgrep
-
-# Part of GNU Sed:
-SED ?= sed
-
-# Part of GNU Privacy Guard:
-GPG ?= gpg
-
-# Part of Texinfo:
-MAKEINFO ?= makeinfo
-MAKEINFO_HTML ?= $(MAKEINFO) --html
-INSTALL_INFO ?= install-info
-
-# Part of Texlive-plainextra:
-TEXI2PDF ?= texi2pdf
-TEXI2DVI ?= texi2dvi
-TEXI2PS ?= texi2pdf --ps
-
-# Part of Texlive-core:
-PS2EPS ?= ps2eps
-
-# Part of librsvg:
-RSVG_CONVERT ?= rsvg-convert
-SVG2PS ?= $(RSVG_CONVERT) --format=ps
-SVG2PDF ?= $(RSVG_CONVERT) --format=pdf
-
-# Part of GNU Compiler Collection:
-CC ?= cc
-CPP ?= cpp
-CXX ?= c++
-
-# Part of GNU Binutils:
-AR ?= ar
-LD ?= ld
-RANLIB ?= ranlib
-
-# Part of GNU Bison:
-BISON ?= bison
-YACC ?= yacc
-
-# Part of Flex:
-FLEX ?= FLEX
-LEX ?= lex
-
-# Part of GNU C Library:
-LDCONFIG ?= ldconfig
-
-# Part of GNU Gettext:
-XGETTEXT ?= xgettext
-MSGFMT ?= msgfmt
-MSGMERGE ?= msgmerge
-MSGINIT ?= msginit
-
-# Part of gzip:
-GZIP ?= gzip
-GZIP_COMPRESS ?= $(GZIP) -k9
-
-# Part of bzip2:
-BZIP2 ?= bzip2
-BZIP2_COMPRESS ?= $(BZIP2) -k9
-
-# Part of xz:
-XZ ?= xz
-XZ_COMPRESS ?= $(XZ) -ke9
-
-# Part of auto-auto-complete:
-AUTO_AUTO_COMPLETE ?= auto-auto-complete
-
-
-# Change to $(TRUE) to suppress the bold red and blue output.
-ifndef PRINTF_INFO
-PRINTF_INFO = $(PRINTF)
-endif
-
-# Change to $(TRUE) to suppress empty lines
-ifndef ECHO_EMPTY
-ECHO_EMPTY = $(ECHO)
-endif
-
diff --git a/src/libcoopgamma.c b/src/libcoopgamma.c
deleted file mode 100644
index 40baf77..0000000
--- a/src/libcoopgamma.c
+++ /dev/null
@@ -1,2620 +0,0 @@
-/**
- * libcoopgamma -- Library for interfacing with cooperative gamma servers
- * Copyright (C) 2016 Mattias Andrée (maandree@kth.se)
- *
- * This library 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 3 of the License, or
- * (at your option) any later version.
- *
- * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
- */
-#define _DEFAULT_SOURCE
-#define _BSD_SOURCE
-
-#include "libcoopgamma.h"
-
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <poll.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-
-
-#if !defined(COOPGAMMAD)
-# define COOPGAMMAD "coopgammad"
-#endif
-
-
-
-#if defined(__clang__)
-# pragma GCC diagnostic ignored "-Wdocumentation"
-# pragma GCC diagnostic ignored "-Wcovered-switch-default"
-# pragma GCC diagnostic ignored "-Wcast-align"
-#endif
-
-
-
-#if defined(__GNUC__)
-# define NAME_OF_THE_PROCESS (argv0)
-extern const char* argv0;
-const char* argv0 __attribute__((weak)) = "libcoopgamma";
-#else
-# define NAME_OF_THE_PROCESS ("libcoopgamma")
-#endif
-
-
-
-#define SUBBUF \
- (buf ? buf + off : NULL)
-
-#define NNSUBBUF \
- (buf + off)
-
-#define MARSHAL_PROLOGUE \
- char* restrict buf = vbuf; \
- size_t off = 0;
-
-#define UNMARSHAL_PROLOGUE \
- const char* restrict buf = vbuf; \
- size_t off = 0;
-
-#define MARSHAL_EPILOGUE \
- return off
-
-#define UNMARSHAL_EPILOGUE \
- return *np = off, LIBCOOPGAMMA_SUCCESS
-
-#define marshal_prim(datum, type) \
- ((buf != NULL ? *(type*)(buf + off) = (datum) : 0), off += sizeof(type))
-
-#define unmarshal_prim(datum, type) \
- ((datum) = *(const type*)(buf + off), off += sizeof(type))
-
-#define marshal_version(version) \
- marshal_prim(version, int)
-
-#define unmarshal_version(version) \
- do \
- { \
- int version__; \
- unmarshal_prim(version__, int); \
- if (version__ < (version)) \
- return LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE; \
- if (version__ > (version)) \
- return LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE; \
- } \
- while (0)
-
-#define marshal_buffer(data, n) \
- ((buf != NULL ? (memcpy(buf + off, (data), (n)), 0) : 0), off += (n))
-
-#define unmarshal_buffer(data, n) \
- do \
- { \
- (data) = malloc(n); \
- if ((data) == NULL) \
- return LIBCOOPGAMMA_ERRNO_SET; \
- memcpy((data), buf + off, (n)); \
- off += (n); \
- } \
- while (0)
-
-#define marshal_string(datum) \
- ((datum) == NULL ? marshal_prim(0, char) : \
- (marshal_prim(1, char), marshal_buffer((datum), strlen(datum) + 1)))
-
-#define unmarshal_string(datum) \
- do \
- { \
- char nonnull__; \
- unmarshal_prim(nonnull__, char); \
- if (nonnull__) \
- unmarshal_buffer((datum), strlen(buf + off) + 1); \
- else \
- (datum) = NULL; \
- } \
- while (0)
-
-
-
-#define copy_errno(ctx) \
- ((errno == 0) ? NULL : \
- ((ctx)->error.number = (uint64_t)errno, \
- (ctx)->error.custom = 0, \
- (ctx)->error.server_side = 0, \
- free((ctx)->error.description), \
- (ctx)->error.description = NULL))
-
-
-#define SYNC_CALL(send_call, recv_call, fail_return) \
- libcoopgamma_async_context_t async; \
- size_t _selected; \
- if (send_call < 0) \
- { \
- reflush: \
- if (errno != EINTR) \
- return fail_return; \
- if (libcoopgamma_flush(ctx) < 0) \
- goto reflush; \
- } \
-resync: \
- if (libcoopgamma_synchronise(ctx, &async, (size_t)1, &_selected) < 0) \
- { \
- if ((errno != EINTR) && (errno != 0)) \
- return fail_return; \
- goto resync; \
- } \
- return recv_call
-
-
-#define INTEGRAL_DEPTHS \
- case LIBCOOPGAMMA_UINT8: \
- case LIBCOOPGAMMA_UINT16: \
- case LIBCOOPGAMMA_UINT32: \
- case LIBCOOPGAMMA_UINT64:
-
-
-
-/**
- * Initialise a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
- * `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`, or `libcoopgamma_rampsd_t`
- *
- * `this->red_size`, `this->green_size`, and `this->blue_size` must already be set
- *
- * @param this The record to initialise
- * @param width The `sizeof(*(this->red))`
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_ramps_initialise_(void* restrict this, size_t width)
-{
- libcoopgamma_ramps8_t* restrict this8 = (libcoopgamma_ramps8_t* restrict)this;
- this8->red = this8->green = this8->blue = NULL;
- this8->red = malloc((this8->red_size + this8->green_size + this8->blue_size) * width);
- if (this8->red == NULL)
- return -1;
- this8->green = this8->red + this8->red_size * width;
- this8->blue = this8->green + this8->green_size * width;
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`,
- * `libcoopgamma_ramps32_t`, `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`,
- * `libcoopgamma_rampsd_t`, or `libcoopgamma_ramps_t`, the allocation of the record
- * itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_ramps_initialise`
- * or failed call to `libcoopgamma_ramps_unmarshal`
- *
- * @param this The record to destroy
- */
-void libcoopgamma_ramps_destroy(void* restrict this)
-{
- libcoopgamma_ramps8_t* restrict this8 = (libcoopgamma_ramps8_t* restrict)this;
- free(this8->red);
- this8->red = this8->green = this8->blue = NULL;
-}
-
-
-/**
- * Marshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
- * `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`, or `libcoopgamma_rampsd_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @param width The `sizeof(*(this->red))`
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_ramps_marshal_(const void* restrict this, void* restrict vbuf, size_t width)
-{
- const libcoopgamma_ramps8_t* restrict this8 = (const libcoopgamma_ramps8_t* restrict)this;
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_RAMPS_VERSION);
- marshal_prim(this8->red_size, size_t);
- marshal_prim(this8->green_size, size_t);
- marshal_prim(this8->blue_size, size_t);
- marshal_buffer(this8->red, (this8->red_size + this8->green_size + this8->blue_size) * width);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_ramps8_t`, `libcoopgamma_ramps16_t`, `libcoopgamma_ramps32_t`,
- * `libcoopgamma_ramps64_t`, `libcoopgamma_rampsf_t`, or `libcoopgamma_rampsd_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @param width The `sizeof(*(this->red))`
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_ramps_unmarshal_(void* restrict this, const void* restrict vbuf,
- size_t* restrict np, size_t width)
-{
- libcoopgamma_ramps8_t* restrict this8 = (libcoopgamma_ramps8_t* restrict)this;
- UNMARSHAL_PROLOGUE;
- unmarshal_version(LIBCOOPGAMMA_RAMPS_VERSION);
- unmarshal_prim(this8->red_size, size_t);
- unmarshal_prim(this8->green_size, size_t);
- unmarshal_prim(this8->blue_size, size_t);
- unmarshal_buffer(this8->red, (this8->red_size + this8->green_size + this8->blue_size) * width);
- this8->green = this8->red + this8->red_size * width;
- this8->blue = this8->green + this8->green_size * width;
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_filter_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_filter_initialise(libcoopgamma_filter_t* restrict this)
-{
- memset(this, 0, sizeof(*this));
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_filter_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_filter_initialise`
- * or failed call to `libcoopgamma_filter_unmarshal`
- *
- * @param this The record to destroy
- */
-void libcoopgamma_filter_destroy(libcoopgamma_filter_t* restrict this)
-{
- free(this->crtc);
- free(this->class);
- free(this->ramps.u8.red);
- memset(this, 0, sizeof(*this));
-}
-
-
-/**
- * Marshal a `libcoopgamma_filter_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_filter_marshal(const libcoopgamma_filter_t* restrict this, void* restrict vbuf)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_FILTER_VERSION);
- marshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
- marshal_version(LIBCOOPGAMMA_LIFESPAN_VERSION);
- marshal_prim(this->depth, libcoopgamma_depth_t);
- marshal_prim(this->priority, int64_t);
- marshal_string(this->crtc);
- marshal_string(this->class);
- marshal_prim(this->lifespan, libcoopgamma_lifespan_t);
- switch (this->depth)
- {
- case LIBCOOPGAMMA_UINT8: off += libcoopgamma_ramps_marshal(&(this->ramps.u8), SUBBUF); break;
- case LIBCOOPGAMMA_UINT16: off += libcoopgamma_ramps_marshal(&(this->ramps.u16), SUBBUF); break;
- case LIBCOOPGAMMA_UINT32: off += libcoopgamma_ramps_marshal(&(this->ramps.u32), SUBBUF); break;
- case LIBCOOPGAMMA_UINT64: off += libcoopgamma_ramps_marshal(&(this->ramps.u64), SUBBUF); break;
- case LIBCOOPGAMMA_FLOAT: off += libcoopgamma_ramps_marshal(&(this->ramps.f), SUBBUF); break;
- case LIBCOOPGAMMA_DOUBLE: off += libcoopgamma_ramps_marshal(&(this->ramps.d), SUBBUF); break;
- default:
- break;
- }
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_filter_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_filter_unmarshal(libcoopgamma_filter_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- int r = LIBCOOPGAMMA_SUCCESS;
- size_t n = 0;
- UNMARSHAL_PROLOGUE;
- memset(this, 0, sizeof(*this));
- unmarshal_version(LIBCOOPGAMMA_FILTER_VERSION);
- unmarshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
- unmarshal_version(LIBCOOPGAMMA_LIFESPAN_VERSION);
- unmarshal_prim(this->depth, libcoopgamma_depth_t);
- unmarshal_prim(this->priority, int64_t);
- unmarshal_string(this->crtc);
- unmarshal_string(this->class);
- unmarshal_prim(this->lifespan, libcoopgamma_lifespan_t);
- switch (this->depth)
- {
- case LIBCOOPGAMMA_UINT8: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u8), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_UINT16: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u16), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_UINT32: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u32), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_UINT64: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u64), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_FLOAT: r = libcoopgamma_ramps_unmarshal(&(this->ramps.f), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_DOUBLE: r = libcoopgamma_ramps_unmarshal(&(this->ramps.d), NNSUBBUF, &n); break;
- default:
- break;
- }
- if (r != LIBCOOPGAMMA_SUCCESS)
- return r;
- off += n;
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_crtc_info_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_crtc_info_initialise(libcoopgamma_crtc_info_t* restrict this)
-{
- memset(this, 0, sizeof(*this));
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_crtc_info_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_crtc_info_initialise`
- * or failed call to `libcoopgamma_crtc_info_unmarshal`
- *
- * @param this The record to destroy
- */
-#if defined(__GNUC__)
-__attribute__((__const__))
-#endif
-void libcoopgamma_crtc_info_destroy(libcoopgamma_crtc_info_t* restrict this)
-{
- (void) this;
-}
-
-
-/**
- * Marshal a `libcoopgamma_crtc_info_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_crtc_info_marshal(const libcoopgamma_crtc_info_t* restrict this, void* restrict vbuf)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_CRTC_INFO_VERSION);
- marshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
- marshal_version(LIBCOOPGAMMA_SUPPORT_VERSION);
- marshal_version(LIBCOOPGAMMA_COLOURSPACE_VERSION);
- marshal_prim(this->cooperative, int);
- marshal_prim(this->depth, libcoopgamma_depth_t);
- marshal_prim(this->red_size, size_t);
- marshal_prim(this->green_size, size_t);
- marshal_prim(this->blue_size, size_t);
- marshal_prim(this->supported, libcoopgamma_support_t);
- marshal_prim(this->colourspace, libcoopgamma_colourspace_t);
- marshal_prim(this->have_gamut, int);
- marshal_prim(this->red_x, unsigned);
- marshal_prim(this->red_y, unsigned);
- marshal_prim(this->green_x, unsigned);
- marshal_prim(this->green_y, unsigned);
- marshal_prim(this->blue_x, unsigned);
- marshal_prim(this->blue_y, unsigned);
- marshal_prim(this->white_x, unsigned);
- marshal_prim(this->white_y, unsigned);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_crtc_info_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_crtc_info_unmarshal(libcoopgamma_crtc_info_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- UNMARSHAL_PROLOGUE;
- unmarshal_version(LIBCOOPGAMMA_CRTC_INFO_VERSION);
- unmarshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
- unmarshal_version(LIBCOOPGAMMA_SUPPORT_VERSION);
- unmarshal_version(LIBCOOPGAMMA_COLOURSPACE_VERSION);
- unmarshal_prim(this->cooperative, int);
- unmarshal_prim(this->depth, libcoopgamma_depth_t);
- unmarshal_prim(this->red_size, size_t);
- unmarshal_prim(this->green_size, size_t);
- unmarshal_prim(this->blue_size, size_t);
- unmarshal_prim(this->supported, libcoopgamma_support_t);
- unmarshal_prim(this->colourspace, libcoopgamma_colourspace_t);
- unmarshal_prim(this->have_gamut, int);
- unmarshal_prim(this->red_x, unsigned);
- unmarshal_prim(this->red_y, unsigned);
- unmarshal_prim(this->green_x, unsigned);
- unmarshal_prim(this->green_y, unsigned);
- unmarshal_prim(this->blue_x, unsigned);
- unmarshal_prim(this->blue_y, unsigned);
- unmarshal_prim(this->white_x, unsigned);
- unmarshal_prim(this->white_y, unsigned);
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_filter_query_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_filter_query_initialise(libcoopgamma_filter_query_t* restrict this)
-{
- this->crtc = NULL;
- this->coalesce = 0;
- this->high_priority = INT64_MAX;
- this->low_priority = INT64_MIN;
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_filter_query_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_filter_query_initialise`
- * or failed call to `libcoopgamma_filter_query_unmarshal`
- *
- * @param this The record to destroy
- */
-void libcoopgamma_filter_query_destroy(libcoopgamma_filter_query_t* restrict this)
-{
- free(this->crtc), this->crtc = NULL;
-}
-
-
-/**
- * Marshal a `libcoopgamma_filter_query_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_filter_query_marshal(const libcoopgamma_filter_query_t* restrict this, void* restrict vbuf)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_FILTER_QUERY_VERSION);
- marshal_string(this->crtc);
- marshal_prim(this->coalesce, int);
- marshal_prim(this->high_priority, int64_t);
- marshal_prim(this->low_priority, int64_t);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_filter_query_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_filter_query_unmarshal(libcoopgamma_filter_query_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- UNMARSHAL_PROLOGUE;
- this->crtc = NULL;
- unmarshal_version(LIBCOOPGAMMA_FILTER_QUERY_VERSION);
- unmarshal_string(this->crtc);
- unmarshal_prim(this->coalesce, int);
- unmarshal_prim(this->high_priority, int64_t);
- unmarshal_prim(this->low_priority, int64_t);
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_queried_filter_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_queried_filter_initialise(libcoopgamma_queried_filter_t* restrict this)
-{
- memset(this, 0, sizeof(*this));
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_queried_filter_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_queried_filter_initialise`
- * or failed call to `libcoopgamma_queried_filter_unmarshal`
- *
- * @param this The record to destroy
- */
-void libcoopgamma_queried_filter_destroy(libcoopgamma_queried_filter_t* restrict this)
-{
- free(this->class), this->class = NULL;
- libcoopgamma_ramps_destroy(&(this->ramps.u8));
-}
-
-
-/**
- * Marshal a `libcoopgamma_queried_filter_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @param depth The type used of ramp stops
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_queried_filter_marshal(const libcoopgamma_queried_filter_t* restrict this,
- void* restrict vbuf, libcoopgamma_depth_t depth)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_QUERIED_FILTER_VERSION);
- marshal_prim(this->priority, int64_t);
- marshal_string(this->class);
- switch (depth)
- {
- case LIBCOOPGAMMA_UINT8: off += libcoopgamma_ramps_marshal(&(this->ramps.u8), SUBBUF); break;
- case LIBCOOPGAMMA_UINT16: off += libcoopgamma_ramps_marshal(&(this->ramps.u16), SUBBUF); break;
- case LIBCOOPGAMMA_UINT32: off += libcoopgamma_ramps_marshal(&(this->ramps.u32), SUBBUF); break;
- case LIBCOOPGAMMA_UINT64: off += libcoopgamma_ramps_marshal(&(this->ramps.u64), SUBBUF); break;
- case LIBCOOPGAMMA_FLOAT: off += libcoopgamma_ramps_marshal(&(this->ramps.f), SUBBUF); break;
- case LIBCOOPGAMMA_DOUBLE: off += libcoopgamma_ramps_marshal(&(this->ramps.d), SUBBUF); break;
- default:
- break;
- }
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_queried_filter_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @param depth The type used of ramp stops
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_queried_filter_unmarshal(libcoopgamma_queried_filter_t* restrict this,
- const void* restrict vbuf, size_t* restrict np,
- libcoopgamma_depth_t depth)
-{
- int r = LIBCOOPGAMMA_SUCCESS;
- size_t n = 0;
- UNMARSHAL_PROLOGUE;
- memset(this, 0, sizeof(*this));
- unmarshal_version(LIBCOOPGAMMA_QUERIED_FILTER_VERSION);
- unmarshal_prim(this->priority, int64_t);
- unmarshal_string(this->class);
- switch (depth)
- {
- case LIBCOOPGAMMA_UINT8: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u8), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_UINT16: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u16), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_UINT32: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u32), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_UINT64: r = libcoopgamma_ramps_unmarshal(&(this->ramps.u64), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_FLOAT: r = libcoopgamma_ramps_unmarshal(&(this->ramps.f), NNSUBBUF, &n); break;
- case LIBCOOPGAMMA_DOUBLE: r = libcoopgamma_ramps_unmarshal(&(this->ramps.d), NNSUBBUF, &n); break;
- default:
- break;
- }
- if (r != LIBCOOPGAMMA_SUCCESS)
- return r;
- off += n;
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_filter_table_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_filter_table_initialise(libcoopgamma_filter_table_t* restrict this)
-{
- memset(this, 0, sizeof(*this));
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_filter_table_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_filter_table_initialise`
- * or failed call to `libcoopgamma_filter_table_unmarshal`
- *
- * @param this The record to destroy
- */
-void libcoopgamma_filter_table_destroy(libcoopgamma_filter_table_t* restrict this)
-{
- while (this->filter_count)
- libcoopgamma_queried_filter_destroy(this->filters + --(this->filter_count));
- free(this->filters), this->filters = NULL;
-}
-
-
-/**
- * Marshal a `libcoopgamma_filter_table_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_filter_table_marshal(const libcoopgamma_filter_table_t* restrict this, void* restrict vbuf)
-{
- size_t i;
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_FILTER_TABLE_VERSION);
- marshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
- marshal_prim(this->depth, libcoopgamma_depth_t);
- marshal_prim(this->red_size, size_t);
- marshal_prim(this->green_size, size_t);
- marshal_prim(this->blue_size, size_t);
- marshal_prim(this->filter_count, size_t);
- for (i = 0; i < this->filter_count; i++)
- off += libcoopgamma_queried_filter_marshal(this->filters + i, SUBBUF, this->depth);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_filter_table_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_filter_table_unmarshal(libcoopgamma_filter_table_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- size_t i, n, fn;
- int r;
- UNMARSHAL_PROLOGUE;
- this->filter_count = 0;
- this->filters = NULL;
- unmarshal_version(LIBCOOPGAMMA_FILTER_TABLE_VERSION);
- unmarshal_version(LIBCOOPGAMMA_DEPTH_VERSION);
- unmarshal_prim(this->depth, libcoopgamma_depth_t);
- unmarshal_prim(this->red_size, size_t);
- unmarshal_prim(this->green_size, size_t);
- unmarshal_prim(this->blue_size, size_t);
- unmarshal_prim(fn, size_t);
- this->filters = malloc(fn * sizeof(*(this->filters)));
- if (this->filters == NULL)
- return LIBCOOPGAMMA_ERRNO_SET;
- for (i = 0; i < fn; i++)
- {
- r = libcoopgamma_queried_filter_unmarshal(this->filters + i, NNSUBBUF, &n, this->depth);
- if (r != LIBCOOPGAMMA_SUCCESS)
- return r;
- off += n;
- this->filter_count += 1;
- }
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_error_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_error_initialise(libcoopgamma_error_t* restrict this)
-{
- this->number = 0;
- this->custom = 0;
- this->description = NULL;
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_error_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_error_initialise`
- * or failed call to `libcoopgamma_error_unmarshal`
- *
- * @param this The record to destroy
- */
-void libcoopgamma_error_destroy(libcoopgamma_error_t* restrict this)
-{
- free(this->description), this->description = NULL;
-}
-
-
-/**
- * Marshal a `libcoopgamma_error_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_error_marshal(const libcoopgamma_error_t* restrict this, void* restrict vbuf)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_ERROR_VERSION);
- marshal_prim(this->number, uint64_t);
- marshal_prim(this->custom, int);
- marshal_prim(this->server_side, int);
- marshal_string(this->description);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_error_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_error_unmarshal(libcoopgamma_error_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- UNMARSHAL_PROLOGUE;
- this->description = NULL;
- unmarshal_version(LIBCOOPGAMMA_ERROR_VERSION);
- unmarshal_prim(this->number, uint64_t);
- unmarshal_prim(this->custom, int);
- unmarshal_prim(this->server_side, int);
- unmarshal_string(this->description);
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_context_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_context_initialise(libcoopgamma_context_t* restrict this)
-{
- memset(this, 0, sizeof(*this));
- this->fd = -1;
- this->blocking = 1;
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_context_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_context_initialise`
- * or failed call to `libcoopgamma_context_unmarshal`
- *
- * @param this The record to destroy
- * @param disconnect Disconnect from the server?
- */
-void libcoopgamma_context_destroy(libcoopgamma_context_t* restrict this, int disconnect)
-{
- if (disconnect && (this->fd >= 0))
- {
- shutdown(this->fd, SHUT_RDWR);
- close(this->fd);
- }
- this->fd = -1;
- libcoopgamma_error_destroy(&(this->error));
- free(this->outbound), this->outbound = NULL;
- free(this->inbound), this->inbound = NULL;
-}
-
-
-/**
- * Marshal a `libcoopgamma_context_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_context_marshal(const libcoopgamma_context_t* restrict this, void* restrict vbuf)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_CONTEXT_VERSION);
- marshal_prim(this->fd, int);
- off += libcoopgamma_error_marshal(&(this->error), SUBBUF);
- marshal_prim(this->message_id, uint32_t);
- marshal_prim(this->outbound_head - this->outbound_tail, size_t);
- marshal_buffer(this->outbound + this->outbound_tail, this->outbound_head - this->outbound_tail);
- marshal_prim(this->inbound_head - this->inbound_tail, size_t);
- marshal_buffer(this->inbound + this->inbound_tail, this->inbound_head - this->inbound_tail);
- marshal_prim(this->length, size_t);
- marshal_prim(this->curline, size_t);
- marshal_prim(this->in_response_to, uint32_t);
- marshal_prim(this->have_all_headers, int);
- marshal_prim(this->bad_message, int);
- marshal_prim(this->blocking, int);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_context_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_context_unmarshal(libcoopgamma_context_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- size_t n;
- int r;
- UNMARSHAL_PROLOGUE;
- memset(this, 0, sizeof(*this));
- unmarshal_version(LIBCOOPGAMMA_CONTEXT_VERSION);
- unmarshal_prim(this->fd, int);
- r = libcoopgamma_error_unmarshal(&(this->error), NNSUBBUF, &n);
- if (r != LIBCOOPGAMMA_SUCCESS)
- return r;
- off += n;
- unmarshal_prim(this->message_id, uint32_t);
- unmarshal_prim(this->outbound_head, size_t);
- this->outbound_size = this->outbound_head;
- unmarshal_buffer(this->outbound, this->outbound_head);
- unmarshal_prim(this->inbound_head, size_t);
- this->inbound_size = this->inbound_head;
- unmarshal_buffer(this->inbound, this->inbound_head);
- unmarshal_prim(this->length, size_t);
- unmarshal_prim(this->curline, size_t);
- unmarshal_prim(this->in_response_to, uint32_t);
- unmarshal_prim(this->have_all_headers, int);
- unmarshal_prim(this->bad_message, int);
- unmarshal_prim(this->blocking, int);
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * Initialise a `libcoopgamma_async_context_t`
- *
- * @param this The record to initialise
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_async_context_initialise(libcoopgamma_async_context_t* restrict this)
-{
- this->message_id = 0;
- this->coalesce = 0;
- return 0;
-}
-
-
-/**
- * Release all resources allocated to a `libcoopgamma_async_context_t`,
- * the allocation of the record itself is not freed
- *
- * Always call this function after failed call to `libcoopgamma_async_context_initialise`
- * or failed call to `libcoopgamma_async_context_unmarshal`
- *
- * @param this The record to destroy
- */
-#if defined(__GNUC__)
-__attribute__((__const__))
-#endif
-void libcoopgamma_async_context_destroy(libcoopgamma_async_context_t* restrict this)
-{
- (void) this;
-}
-
-
-/**
- * Marshal a `libcoopgamma_async_context_t` into a buffer
- *
- * @param this The record to marshal
- * @param vbuf The output buffer, `NULL` to only measure
- * how large this buffer has to be
- * @return The number of marshalled bytes, or if `buf == NULL`,
- * how many bytes would be marshalled if `buf != NULL`
- */
-size_t libcoopgamma_async_context_marshal(const libcoopgamma_async_context_t* restrict this,
- void* restrict vbuf)
-{
- MARSHAL_PROLOGUE;
- marshal_version(LIBCOOPGAMMA_ASYNC_CONTEXT_VERSION);
- marshal_prim(this->message_id, uint32_t);
- marshal_prim(this->coalesce, int);
- MARSHAL_EPILOGUE;
-}
-
-
-/**
- * Unmarshal a `libcoopgamma_async_context_t` from a buffer
- *
- * @param this The output parameter for unmarshalled record
- * @param vbuf The buffer with the marshalled record
- * @param np Output parameter for the number of unmarshalled bytes, undefined on failure
- * @return `LIBCOOPGAMMA_SUCCESS` (0), `LIBCOOPGAMMA_INCOMPATIBLE_DOWNGRADE`,
- * `LIBCOOPGAMMA_INCOMPATIBLE_UPGRADE`, or `LIBCOOPGAMMA_ERRNO_SET`
- */
-int libcoopgamma_async_context_unmarshal(libcoopgamma_async_context_t* restrict this,
- const void* restrict vbuf, size_t* restrict np)
-{
- UNMARSHAL_PROLOGUE;
- unmarshal_version(LIBCOOPGAMMA_ASYNC_CONTEXT_VERSION);
- unmarshal_prim(this->message_id, uint32_t);
- unmarshal_prim(this->coalesce, int);
- UNMARSHAL_EPILOGUE;
-}
-
-
-
-/**
- * List all recognised adjustment method
- *
- * SIGCHLD must not be ignored or blocked
- *
- * @return A `NULL`-terminated list of names. You should only free
- * the outer pointer, inner pointers are subpointers of the
- * outer pointer and cannot be freed. `NULL` on error.
- */
-char** libcoopgamma_get_methods(void)
-{
- char num[5]; /* The size is base on the fact that we have limited `n` in the loop below */
- char** methods = NULL;
- char** rc;
- char* buffer;
- int n = 0, saved_errno;
- size_t size = 0;
-
- methods = malloc(4 * sizeof(*methods));
- if (methods == NULL)
- goto fail;
-
- for (n = 0; n < 10000 /* just to be safe */; n++)
- {
- char* method;
- if ((n >= 4) && ((n & -n) == n))
- {
- void* new = realloc(methods, (size_t)(n << 1) * sizeof(*methods));
- if (new == NULL)
- goto fail;
- methods = new;
- }
- sprintf(num, "%i", n);
- if (libcoopgamma_get_method_and_site(num, NULL, &method, NULL))
- goto fail;
- if (!strcmp(method, num))
- {
- free(method);
- break;
- }
- methods[n] = method;
- size += strlen(method) + 1;
- }
-
- rc = malloc((size_t)(n + 1) * sizeof(char*) + size);
- if (rc == NULL)
- goto fail;
- buffer = ((char*)rc) + (size_t)(n + 1) * sizeof(char*);
- rc[n] = NULL;
- while (n--)
- {
- rc[n] = buffer;
- buffer = stpcpy(buffer, methods[n]) + 1;
- free(methods[n]);
- }
- free(methods);
-
- return rc;
-
- fail:
- saved_errno = errno;
- while (n--)
- free(methods[n]);
- free(methods);
- errno = saved_errno;
- return NULL;
-}
-
-
-/**
- * Run coopgammad with -q or -qq and return the response
- *
- * SIGCHLD must not be ignored or blocked
- *
- * @param method The adjustment method, `NULL` for automatic
- * @param site The site, `NULL` for automatic
- * @param arg "-q" or "-qq", which shall be passed to coopgammad?
- * @return The output of coopgammad, `NULL` on error. This
- * will be NUL-terminated and will not contain any
- * other `NUL` bytes.
- */
-static char* libcoopgamma_query(const char* restrict method, const char* restrict site, const char* restrict arg)
-{
- const char* (args[7]) = {COOPGAMMAD, arg};
- size_t i = 2, n = 0, size = 0;
- int pipe_rw[2] = { -1, -1 };
- pid_t pid;
- int saved_errno, status;
- char* msg = NULL;
- ssize_t got;
-
- if (method != NULL) args[i++] = "-m", args[i++] = method;
- if (site != NULL) args[i++] = "-s", args[i++] = site;
- args[i] = NULL;
-
- if (pipe(pipe_rw) < 0)
- goto fail;
-
- switch ((pid = fork()))
- {
- case -1:
- goto fail;
- case 0:
- /* Child */
- close(pipe_rw[0]);
- if (pipe_rw[1] != STDOUT_FILENO)
- {
- close(STDOUT_FILENO);
- if (dup2(pipe_rw[1], STDOUT_FILENO) < 0)
- goto fail_child;
- close(pipe_rw[1]);
- }
-#if defined(__GNUC__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
- execvp(COOPGAMMAD, (char* const*)(args));
-#if defined(__GNUC__)
-# pragma GCC diagnostic pop
-#endif
- fail_child:
- saved_errno = errno;
- perror(NAME_OF_THE_PROCESS);
- if (write(STDOUT_FILENO, &saved_errno, sizeof(int)) != sizeof(int))
- perror(NAME_OF_THE_PROCESS);
- exit(1);
- default:
- /* Parent */
- close(pipe_rw[1]), pipe_rw[1] = -1;
- for (;;)
- {
- if (n == size)
- {
- void* new = realloc(msg, size = (n ? (n << 1) : 256));
- if (new == NULL)
- goto fail;
- msg = new;
- }
- got = read(pipe_rw[0], msg + n, size - n);
- if (got < 0)
- {
- if (errno == EINTR)
- continue;
- goto fail;
- }
- else if (got == 0)
- break;
- n += (size_t)got;
- }
- close(pipe_rw[0]), pipe_rw[0] = -1;
- if (waitpid(pid, &status, 0) < 0)
- goto fail;
- if (status)
- {
- errno = EINVAL;
- if ((n == sizeof(int)) && (*(int*)msg != 0))
- errno = *(int*)msg;
- }
- break;
- }
-
- if (n == size)
- {
- void* new = realloc(msg, n + 1);
- if (new == NULL)
- goto fail;
- msg = new;
- }
- msg[n] = '\0';
-
- if (strchr(msg, '\0') != msg + n)
- {
- errno = EBADMSG;
- goto fail;
- }
-
- return msg;
- fail:
- saved_errno = errno;
- if (pipe_rw[0] >= 0) close(pipe_rw[0]);
- if (pipe_rw[1] >= 0) close(pipe_rw[1]);
- free(msg);
- errno = saved_errno;
- return NULL;
-}
-
-
-/**
- * Get the adjustment method and site
- *
- * SIGCHLD must not be ignored or blocked
- *
- * @param method The adjustment method, `NULL` for automatic
- * @param site The site, `NULL` for automatic
- * @param methodp Output pointer for the selected adjustment method,
- * which cannot be `NULL`. It is safe to call
- * this function with this parameter set to `NULL`.
- * @param sitep Output pointer for the selected site, which will
- * be `NULL` the method only supports one site or if
- * `site == NULL` and no site can be selected
- * automatically. It is safe to call this function
- * with this parameter set to `NULL`.
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_get_method_and_site(const char* restrict method, const char* restrict site,
- char** restrict methodp, char** restrict sitep)
-{
- int saved_errno;
- char* raw;
- char* p;
- char* q;
-
- raw = libcoopgamma_query(method, site, "-q");
- if (raw == NULL)
- return -1;
-
- if (methodp != NULL) *methodp = NULL;
- if (sitep != NULL) *sitep = NULL;
-
- p = strchr(raw, '\n');
- if (p == NULL)
- {
- errno = EBADMSG;
- goto fail;
- }
- *p++ = '\0';
-
- if (methodp != NULL)
- {
- *methodp = malloc(strlen(raw) + 1);
- if (*methodp == NULL)
- goto fail;
- strcpy(*methodp, raw);
- }
-
- if ((site != NULL) && *(q = strchr(p, '\0') - 1))
- {
- if (*q != '\n')
- {
- errno = EBADMSG;
- goto fail;
- }
- *q = '\0';
- *sitep = malloc(strlen(p) + 1);
- if (*sitep == NULL)
- goto fail;
- strcpy(*sitep, p);
- }
-
- free(raw);
- return 0;
- fail:
- saved_errno = errno;
- if (methodp != NULL)
- free(*methodp), *methodp = NULL;
- free(raw);
- errno = saved_errno;
- return -1;
-}
-
-
-/**
- * Get the PID file of the coopgamma server
- *
- * SIGCHLD must not be ignored or blocked
- *
- * @param method The adjustment method, `NULL` for automatic
- * @param site The site, `NULL` for automatic
- * @return The pathname of the server's PID file, `NULL` on error
- * or if there server does not use PID files. The later
- * case is detected by checking that `errno` is set to 0.
- */
-char* libcoopgamma_get_pid_file(const char* restrict method, const char* restrict site)
-{
- char* path;
- size_t n;
-
- path = libcoopgamma_get_socket_file(method, site);
- if (path == NULL)
- return NULL;
-
- n = strlen(path);
- if (n < 7 || strcmp(path + n - 7, ".socket"))
- {
- free(path);
- errno = EBADMSG;
- return NULL;
- }
-
- strcpy(path + n - 7, ".pid");
- return path;
-}
-
-
-/**
- * Get the socket file of the coopgamma server
- *
- * SIGCHLD must not be ignored or blocked
- *
- * @param method The adjustment method, `NULL` for automatic
- * @param site The site, `NULL` for automatic
- * @return The pathname of the server's socket, `NULL` on error
- * or if there server does have its own socket. The later
- * case is detected by checking that `errno` is set to 0,
- * and is the case when communicating with a server in a
- * multi-server display server like mds.
- */
-char* libcoopgamma_get_socket_file(const char* restrict method, const char* restrict site)
-{
- int saved_errno;
- char* raw;
- char* p;
-
- raw = libcoopgamma_query(method, site, "-qq");
- if (raw == NULL)
- return NULL;
-
- p = strchr(raw, '\0') - 1;
- if ((p < raw) || (*p != '\n'))
- {
- errno = EBADMSG;
- goto fail;
- }
- *p = '\0';
- if (*raw == '\0')
- {
- errno = EBADMSG;
- goto fail;
- }
-
- return raw;
- fail:
- saved_errno = errno;
- free(raw);
- errno = saved_errno;
- return NULL;
-}
-
-
-
-/**
- * Connect to a coopgamma server, and start it if necessary
- *
- * Use `libcoopgamma_context_destroy` to disconnect
- *
- * SIGCHLD must not be ignored or blocked
- *
- * @param method The adjustment method, `NULL` for automatic
- * @param site The site, `NULL` for automatic
- * @param ctx The state of the library, must be initialised
- * @return Zero on success, -1 on error. On error, `errno` is set
- * to 0 if the server could not be initialised.
- */
-int libcoopgamma_connect(const char* restrict method, const char* restrict site,
- libcoopgamma_context_t* restrict ctx)
-{
- const char* (args[6]) = {COOPGAMMAD};
- struct sockaddr_un address;
- char* path;
- int saved_errno;
- int tries = 0, status;
- pid_t pid;
- size_t i = 1;
-
- ctx->blocking = 1;
-
- if (method != NULL) args[i++] = "-m", args[i++] = method;
- if (site != NULL) args[i++] = "-s", args[i++] = site;
- args[i] = NULL;
-
- path = libcoopgamma_get_socket_file(method, site);
- if (path == NULL)
- return -1;
- if (strlen(path) >= sizeof(address.sun_path))
- {
- free(path);
- errno = ENAMETOOLONG;
- return -1;
- }
-
- address.sun_family = AF_UNIX;
- strcpy(address.sun_path, path);
- free(path);
- if ((ctx->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
- return -1;
-
- retry:
- if (connect(ctx->fd, (struct sockaddr*)(&address), (socklen_t)sizeof(address)) < 0)
- {
- if (((errno == ECONNREFUSED) || (errno == ENOENT) || (errno == ENOTDIR)) && !tries++)
- {
- switch ((pid = fork()))
- {
- case -1:
- goto fail;
- case 0:
- /* Child */
- close(ctx->fd);
-#if defined(__GNUC__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
- execvp(COOPGAMMAD, (char* const*)(args));
-#if defined(__GNUC__)
-# pragma GCC diagnostic pop
-#endif
- perror(NAME_OF_THE_PROCESS);
- exit(1);
- default:
- /* Parent */
- if (waitpid(pid, &status, 0) < 0)
- goto fail;
- if (status)
- {
- errno = 0;
- goto fail;
- }
- break;
- }
- goto retry;
- }
- goto fail;
- }
-
- return 0;
- fail:
- saved_errno = errno;
- close(ctx->fd), ctx->fd = -1;
- errno = saved_errno;
- return -1;
-}
-
-
-/**
- * By default communication is blocking, this function
- * can be used to switch between blocking and nonblocking
- *
- * After setting the communication to nonblocking,
- * `libcoopgamma_flush`, `libcoopgamma_synchronise` and
- * and request-sending functions can fail with EAGAIN and
- * EWOULDBLOCK. It is safe to continue with `libcoopgamma_flush`
- * (for `libcoopgamma_flush` it selfand equest-sending functions)
- * or `libcoopgamma_synchronise` just like EINTR failure.
- *
- * @param ctx The state of the library, must be connected
- * @param nonblocking Nonblocking mode?
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_set_nonblocking(libcoopgamma_context_t* restrict ctx, int nonblocking)
-{
- int flags = fcntl(ctx->fd, F_GETFL);
- if (flags == -1)
- return -1;
- if (nonblocking)
- flags |= O_NONBLOCK;
- else
- flags &= ~O_NONBLOCK;
- if (fcntl(ctx->fd, F_SETFL, flags) == -1)
- return -1;
- ctx->blocking = !nonblocking;
- return 0;
-}
-
-
-/**
- * Send all pending outbound data
- *
- * If this function or another function that sends a request
- * to the server fails with EINTR, call this function to
- * complete the transfer. The `async` parameter will always
- * be in a properly configured state if a function fails
- * with EINTR.
- *
- * @param ctx The state of the library, must be connected
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_flush(libcoopgamma_context_t* restrict ctx)
-{
- ssize_t sent;
- size_t chunksize = ctx->outbound_head - ctx->outbound_tail;
- size_t sendsize;
-
- while (ctx->outbound_tail < ctx->outbound_head)
- {
- sendsize = ctx->outbound_head - ctx->outbound_tail;
- sendsize = sendsize < chunksize ? sendsize : chunksize;
- sent = send(ctx->fd, ctx->outbound + ctx->outbound_tail, sendsize, MSG_NOSIGNAL);
- if (sent < 0)
- {
- if (errno == EPIPE)
- errno = ECONNRESET;
- if (errno != EMSGSIZE)
- return -1;
- if ((chunksize >>= 1) == 0)
- return -1;
- continue;
- }
-
-#ifdef DEBUG_MODE
- fprintf(stderr, "\033[31m");
- fwrite(ctx->outbound + ctx->outbound_tail, (size_t)sent, 1, stderr);
- fprintf(stderr, "\033[m");
- fflush(stderr);
-#endif
-
- ctx->outbound_tail += (size_t)sent;
- }
-
- return 0;
-}
-
-
-/**
- * Wait for the next message to be received
- *
- * @param ctx The state of the library, must be connected
- * @param pending Information for each pending request
- * @param n The number of elements in `pending`
- * @param selected The index of the element in `pending` which corresponds
- * to the first inbound message, note that this only means
- * that the message is not for any of the other request,
- * if the message is corrupt any of the listed requests can
- * be selected even if it is not for any of the requests.
- * Functions that parse the message will detect such corruption.
- * @return Zero on success, -1 on error. If the the message is ignored,
- * which happens if corresponding `libcoopgamma_async_context_t`
- * is not listed, -1 is returned and `errno` is set to 0. If -1
- * is returned, `errno` is set to `ENOTRECOVERABLE` you have
- * received a corrupt message and the context has been tainted
- * beyond recover.
- */
-int libcoopgamma_synchronise(libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict pending,
- size_t n, size_t* restrict selected)
-{
- char temp[3 * sizeof(size_t) + 1];
- ssize_t got;
- size_t i;
- char* p;
- char* line;
- char* value;
- struct pollfd pollfd;
-
- if (ctx->inbound_head == ctx->inbound_tail)
- ctx->inbound_head = ctx->inbound_tail = ctx->curline = 0;
- else if (ctx->inbound_tail > 0)
- {
- memmove(ctx->inbound, ctx->inbound + ctx->inbound_tail, ctx->inbound_head -= ctx->inbound_tail);
- ctx->curline -= ctx->inbound_tail;
- ctx->inbound_tail = 0;
- }
-
- pollfd.fd = ctx->fd;
- pollfd.events = POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI;
-
- if (ctx->inbound_head)
- goto skip_recv;
- for (;;)
- {
- if (ctx->inbound_head == ctx->inbound_size)
- {
- size_t new_size = ctx->inbound_size ? (ctx->inbound_size << 1) : 1024;
- void* new = realloc(ctx->inbound, new_size);
- if (new == NULL)
- return -1;
- ctx->inbound = new;
- ctx->inbound_size = new_size;
- }
-
- if (ctx->blocking)
- {
- pollfd.revents = 0;
- if (poll(&pollfd, (nfds_t)1, -1) < 0)
- return -1;
- }
- got = recv(ctx->fd, ctx->inbound + ctx->inbound_head, ctx->inbound_size - ctx->inbound_head, 0);
- if (got <= 0)
- {
- if (got == 0)
- errno = ECONNRESET;
- return -1;
- }
-
-#ifdef DEBUG_MODE
- fprintf(stderr, "\033[32m");
- fwrite(ctx->inbound + ctx->inbound_head, (size_t)got, 1, stderr);
- fprintf(stderr, "\033[m");
- fflush(stderr);
-#endif
-
- ctx->inbound_head += (size_t)got;
-
- skip_recv:
- while (ctx->have_all_headers == 0)
- {
- line = ctx->inbound + ctx->curline;
- p = memchr(line, '\n', ctx->inbound_head - ctx->curline);
- if (p == NULL)
- break;
- if (memchr(line, '\0', (size_t)(p - line)) != NULL)
- ctx->bad_message = 1;
- *p++ = '\0';
- ctx->curline = (size_t)(p - ctx->inbound);
- if (!*line)
- {
- ctx->have_all_headers = 1;
- }
- else if (strstr(line, "In response to: ") == line)
- {
- value = line + (sizeof("In response to: ") - 1);
- ctx->in_response_to = (uint32_t)atol(value);
- }
- else if (strstr(line, "Length: ") == line)
- {
- value = line + (sizeof("Length: ") - 1);
- ctx->length = (size_t)atol(value);
- sprintf(temp, "%zu", ctx->length);
- if (strcmp(value, temp))
- goto fatal;
- }
- }
-
- if (ctx->have_all_headers && (ctx->inbound_head >= ctx->curline + ctx->length))
- {
- ctx->curline += ctx->length;
- if (ctx->bad_message)
- {
- ctx->bad_message = 0;
- ctx->have_all_headers = 0;
- ctx->length = 0;
- ctx->inbound_tail = ctx->curline;
- errno = EBADMSG;
- return -1;
- }
- for (i = 0; i < n; i++)
- if (pending[i].message_id == ctx->in_response_to)
- {
- *selected = i;
- return 0;
- }
- *selected = 0;
- ctx->bad_message = 0;
- ctx->have_all_headers = 0;
- ctx->length = 0;
- ctx->inbound_tail = ctx->curline;
- errno = 0;
- return -1;
- }
- }
-
- fatal:
- errno = ENOTRECOVERABLE;
- return -1;
-}
-
-
-/**
- * Send a message to the server and wait for response
- *
- * @param resp:char** Output parameter for the response,
- * will be NUL-terminated
- * @param ctx:libcoopgamma_context_t* The state of the library
- * @param payload:void* Data to append to the end of the message
- * @param payload_size:size_t Byte-size of `payload`
- * @param format:string-literal Message formatting string
- * @param ... Message formatting arguments
- *
- * On error, the macro goes to `fail`.
- */
-#define SEND_MESSAGE(ctx, payload, payload_size, format, ...) \
- do \
- { \
- ssize_t n__; \
- char* msg__; \
- snprintf(NULL, (size_t)0, format "%zn", __VA_ARGS__, &n__); \
- msg__ = malloc((size_t)n__ + (payload_size) + (size_t)1); \
- if (msg__ == NULL) \
- goto fail; \
- sprintf(msg__, format, __VA_ARGS__); \
- if ((payload) != NULL) \
- memcpy(msg__ + n__, (payload), (payload_size)); \
- if (send_message((ctx), msg__, (size_t)n__ + (payload_size)) < 0) \
- goto fail; \
- } \
- while (0)
-
-
-/**
- * Send a message to the server and wait for response
- *
- * @param ctx The state of the library
- * @param msg The message to send
- * @param n The length of `msg`
- * @return Zero on success, -1 on error
- */
-static int send_message(libcoopgamma_context_t* restrict ctx, char* msg, size_t n)
-{
- if (ctx->outbound_head == ctx->outbound_tail)
- {
- free(ctx->outbound);
- ctx->outbound = msg;
- ctx->outbound_tail = 0;
- ctx->outbound_head = n;
- ctx->outbound_size = n;
- }
- else
- {
- if (ctx->outbound_head + n > ctx->outbound_size)
- {
- memmove(ctx->outbound, ctx->outbound + ctx->outbound_tail, ctx->outbound_head -= ctx->outbound_tail);
- ctx->outbound_tail = 0;
- }
- if (ctx->outbound_head + n > ctx->outbound_size)
- {
- void* new = realloc(ctx->outbound, ctx->outbound_head + n);
- if (new == NULL)
- {
- int saved_errno = errno;
- free(msg);
- errno = saved_errno;
- return -1;
- }
- ctx->outbound = new;
- ctx->outbound_size = ctx->outbound_head + n;
- }
- memcpy(ctx->outbound + ctx->outbound_head, msg, n);
- ctx->outbound_head += n;
- free(msg);
- }
- ctx->message_id += 1;
- return libcoopgamma_flush(ctx);
-}
-
-
-/**
- * Get the next header of the inbound message
- *
- * All headers must be read before the payload is read
- *
- * @param ctx The state of the library, must be connected
- * @return The next header line, can never be `NULL`,
- * the empty string marks the end of the headers.
- * This memory segment must not be freed.
- */
-static char* next_header(libcoopgamma_context_t* restrict ctx)
-{
- char* rc = ctx->inbound + ctx->inbound_tail;
- ctx->inbound_tail += strlen(rc) + 1;
- return rc;
-}
-
-
-/**
- * Get the payload of the inbound message
- *
- * Calling this function marks that the inbound message
- * has been fully ready. You must call this function
- * even if you do not expect a payload
- *
- * @param ctx The state of the library, must be connected
- * @param n Output parameter for the size of the payload
- * @return The payload (not NUL-terminated), `NULL` if
- * there is no payload. Failure is impossible.
- * This memory segment must not be freed.
- */
-static char* next_payload(libcoopgamma_context_t* restrict ctx, size_t* n)
-{
- ctx->have_all_headers = 0;
- if ((*n = ctx->length))
- {
- char* rc = ctx->inbound + ctx->inbound_tail;
- ctx->inbound_tail += *n;
- ctx->length = 0;
- return rc;
- }
- else
- return NULL;
-}
-
-
-/**
- * Tell the library that you will not be parsing a receive message
- *
- * @param ctx The state of the library, must be connected
- */
-void libcoopgamma_skip_message(libcoopgamma_context_t* restrict ctx)
-{
- size_t _n;
- while (*next_header(ctx));
- (void) next_payload(ctx, &_n);
-}
-
-
-/**
- * Check whether the server sent an error, if so copy it to `ctx`
- *
- * This function will also reports EBADMSG if the message ID
- * that the message is a response to does not match the request
- * information, or if it is missing
- *
- * @param ctx The state of the library, must be connected
- * @param async Information about the request
- * @return 1 if the server sent an error (even indicating success),
- * 0 on success, -1 on failure. Information about failure
- * is copied `ctx`.
- */
-static int check_error(libcoopgamma_context_t* restrict ctx, libcoopgamma_async_context_t* restrict async)
-{
- char temp[3 * sizeof(uint64_t) + 1];
- size_t old_tail = ctx->inbound_tail;
- char* line;
- char* value;
- int command_ok = 0;
- int have_in_response_to = 0;
- int have_error = 0;
- int bad = 0;
- char* payload;
- size_t n;
-
- for (;;)
- {
- line = next_header(ctx);
- value = strchr(line, ':') + 2;
- if (!*line)
- break;
- else if (!strcmp(line, "Command: error"))
- command_ok = 1;
- else if (strstr(line, "In response to: ") == line)
- {
- uint32_t id = (uint32_t)atol(value);
- have_in_response_to = 1 + !!have_in_response_to;
- if (id != async->message_id)
- bad = 1;
- else
- {
- sprintf(temp, "%" PRIu32, id);
- if (strcmp(value, temp))
- bad = 1;
- }
- }
- else if (strstr(line, "Error: ") == line)
- {
- have_error = 1 + !!have_error;
- ctx->error.server_side = 1;
- ctx->error.custom = (strstr(value, "custom") == value);
- if (ctx->error.custom)
- {
- if (value[6] == '\0')
- {
- ctx->error.number = 0;
- continue;
- }
- else if (value[6] != ' ')
- {
- bad = 1;
- continue;
- }
- value += 7;
- }
- ctx->error.number = (uint64_t)atoll(value);
- sprintf(temp, "%" PRIu64, ctx->error.number);
- if (strcmp(value, temp))
- bad = 1;
- }
- }
-
- if (command_ok == 0)
- {
- ctx->inbound_tail = old_tail;
- return 0;
- }
-
- payload = next_payload(ctx, &n);
- if (payload != NULL)
- {
- if (memchr(payload, '\0', n) || (payload[n - 1] != '\n'))
- goto badmsg;
- ctx->error.description = malloc(n);
- if (ctx->error.description == NULL)
- goto fail;
- memcpy(ctx->error.description, payload, n - 1);
- ctx->error.description[n - 1] = '\0';
- }
-
- if (bad || (have_in_response_to != 1) || (have_error != 1))
- goto badmsg;
-
- return 1;
-badmsg:
- errno = EBADMSG;
-fail:
- copy_errno(ctx);
- return -1;
-}
-
-
-
-#if defined(__GNUC__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wnonnull"
-#endif
-
-
-
-/**
- * List all available CRTC:s, send request part
- *
- * Cannot be used before connecting to the server
- *
- * @param ctx The state of the library, must be connected
- * @param async Information about the request, that is needed to
- * identify and parse the response, is stored here
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_get_crtcs_send(libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
- async->message_id = ctx->message_id;
- SEND_MESSAGE(ctx, NULL, (size_t)0,
- "Command: enumerate-crtcs\n"
- "Message ID: %" PRIu32 "\n"
- "\n",
- ctx->message_id);
-
- return 0;
- fail:
- copy_errno(ctx);
- return -1;
-}
-
-
-/**
- * List all available CRTC:s, receive response part
- *
- * @param ctx The state of the library, must be connected
- * @param async Information about the request
- * @return A `NULL`-terminated list of names. You should only free
- * the outer pointer, inner pointers are subpointers of the
- * outer pointer and cannot be freed. `NULL` on error, in
- * which case `ctx->error` (rather than `errno`) is read
- * for information about the error.
- */
-char** libcoopgamma_get_crtcs_recv(libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
- char* line;
- char* payload;
- char* end;
- int command_ok = 0;
- size_t i, n, lines, len, length;
- char** rc;
-
- if (check_error(ctx, async))
- return NULL;
-
- for (;;)
- {
- line = next_header(ctx);
- if (!*line)
- break;
- else if (!strcmp(line, "Command: crtc-enumeration"))
- command_ok = 1;
- }
-
- payload = next_payload(ctx, &n);
-
- if (!command_ok || ((n > 0) && (payload[n - 1] != '\n')))
- {
- errno = EBADMSG;
- copy_errno(ctx);
- return NULL;
- }
-
- line = payload;
- end = payload + n;
- lines = length = 0;
- while (line != end)
- {
- lines += 1;
- length += len = (size_t)(strchr(line, '\n') + 1 - line);
- line += len;
- line[-1] = '\0';
- }
-
- rc = malloc((lines + 1) * sizeof(char*) + length);
- if (rc == NULL)
- {
- copy_errno(ctx);
- return NULL;
- }
-
- line = ((char*)rc) + (lines + 1) * sizeof(char*);
- memcpy(line, payload, length);
- rc[lines] = NULL;
- for (i = 0; i < lines; i++)
- {
- rc[i] = line;
- line = strchr(line, '\0') + 1;
- }
-
- return rc;
-}
-
-
-/**
- * List all available CRTC:s, synchronous version
- *
- * This is a synchronous request function, as such,
- * you have to ensure that communication is blocking
- * (default), and that there are not asynchronous
- * requests waiting, it also means that EINTR:s are
- * silently ignored and there no wait to cancel the
- * operation without disconnection from the server
- *
- * @param ctx The state of the library, must be connected
- * @return A `NULL`-terminated list of names. You should only free
- * the outer pointer, inner pointers are subpointers of the
- * outer pointer and cannot be freed. `NULL` on error, in
- * which case `ctx->error` (rather than `errno`) is read
- * for information about the error.
- */
-char** libcoopgamma_get_crtcs_sync(libcoopgamma_context_t* restrict ctx)
-{
- SYNC_CALL(libcoopgamma_get_crtcs_send(ctx, &async),
- libcoopgamma_get_crtcs_recv(ctx, &async), (copy_errno(ctx), NULL));
-}
-
-
-
-/**
- * Retrieve information about a CRTC:s gamma ramps, send request part
- *
- * Cannot be used before connecting to the server
- *
- * @param crtc The name of the CRTC
- * @param ctx The state of the library, must be connected
- * @param async Information about the request, that is needed to
- * identify and parse the response, is stored here
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_get_gamma_info_send(const char* restrict crtc, libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wnonnull-compare"
-#endif
- if ((crtc == NULL) || strchr(crtc, '\n'))
- {
- errno = EINVAL;
- goto fail;
- }
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic pop
-#endif
-
- async->message_id = ctx->message_id;
- SEND_MESSAGE(ctx, NULL, (size_t)0,
- "Command: get-gamma-info\n"
- "Message ID: %" PRIu32 "\n"
- "CRTC: %s\n"
- "\n",
- ctx->message_id, crtc);
-
- return 0;
- fail:
- copy_errno(ctx);
- return 0;
-}
-
-
-/**
- * Retrieve information about a CRTC:s gamma ramps, receive response part
- *
- * @param info Output parameter for the information, must be initialised
- * @param ctx The state of the library, must be connected
- * @param async Information about the request
- * @return Zero on success, -1 on error, in which case `ctx->error`
- * (rather than `errno`) is read for information about the error
- */
-int libcoopgamma_get_gamma_info_recv(libcoopgamma_crtc_info_t* restrict info,
- libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
- char temp[3 * sizeof(size_t) + 1];
- char* line;
- char* value;
- size_t _n;
- int have_cooperative = 0, have_gamma_support = 0, have_colourspace = 0;
- int have_depth = 0, have_white_x = 0, have_white_y = 0;
- int have_red_size = 0, have_red_x = 0, have_red_y = 0;
- int have_green_size = 0, have_green_x = 0, have_green_y = 0;
- int have_blue_size = 0, have_blue_x = 0, have_blue_y = 0;
- int bad = 0, r = 0, g = 0, b = 0, x = 0;
-
- if (check_error(ctx, async))
- return -1;
-
- info->cooperative = 0; /* Should be in the response, but ... */
- info->colourspace = LIBCOOPGAMMA_UNKNOWN;
-
- for (;;)
- {
- line = next_header(ctx);
- value = strchr(line, ':') + 2;
- if (!*line)
- break;
- else if (strstr(line, "Cooperative: ") == line)
- {
- have_cooperative = 1 + !!have_cooperative;
- if (!strcmp(value, "yes")) info->cooperative = 1;
- else if (!strcmp(value, "no")) info->cooperative = 0;
- else
- bad = 1;
- }
- else if (strstr(line, "Depth: ") == line)
- {
- have_depth = 1 + !!have_depth;
- if (!strcmp(value, "8")) info->depth = LIBCOOPGAMMA_UINT8;
- else if (!strcmp(value, "16")) info->depth = LIBCOOPGAMMA_UINT16;
- else if (!strcmp(value, "32")) info->depth = LIBCOOPGAMMA_UINT32;
- else if (!strcmp(value, "64")) info->depth = LIBCOOPGAMMA_UINT64;
- else if (!strcmp(value, "f")) info->depth = LIBCOOPGAMMA_FLOAT;
- else if (!strcmp(value, "d")) info->depth = LIBCOOPGAMMA_DOUBLE;
- else
- bad = 1;
- }
- else if (strstr(line, "Gamma support: ") == line)
- {
- have_gamma_support = 1 + !!have_gamma_support;
- if (!strcmp(value, "yes")) info->supported = LIBCOOPGAMMA_YES;
- else if (!strcmp(value, "no")) info->supported = LIBCOOPGAMMA_NO;
- else if (!strcmp(value, "maybe")) info->supported = LIBCOOPGAMMA_MAYBE;
- else
- bad = 1;
- }
- else if (((r = (strstr(line, "Red size: ") == line))) ||
- ((g = (strstr(line, "Green size: ") == line))) ||
- (strstr(line, "Blue size: ") == line))
- {
- size_t* out;
- if (r) have_red_size = 1 + !!have_red_size, out = &(info->red_size);
- else if (g) have_green_size = 1 + !!have_green_size, out = &(info->green_size);
- else have_blue_size = 1 + !!have_blue_size, out = &(info->blue_size);
- *out = (size_t)atol(value);
- sprintf(temp, "%zu", *out);
- if (strcmp(value, temp))
- bad = 1;
- }
- else if ((x = r = (strstr(line, "Red x: ") == line)) ||
- (r = (strstr(line, "Red y: ") == line)) ||
- (x = g = (strstr(line, "Green x: ") == line)) ||
- (g = (strstr(line, "Green y: ") == line)) ||
- (x = b = (strstr(line, "Blue x: ") == line)) ||
- (b = (strstr(line, "Blue y: ") == line)) ||
- (x = (strstr(line, "White x: ") == line)) ||
- (strstr(line, "White y: ") == line))
- {
- unsigned* out;
- int* have;
- if (r && x) have = &have_red_x, out = &(info->red_x);
- else if (r) have = &have_red_y, out = &(info->red_y);
- else if (g && x) have = &have_green_x, out = &(info->green_x);
- else if (g) have = &have_green_y, out = &(info->green_y);
- else if (b && x) have = &have_blue_x, out = &(info->blue_x);
- else if (b) have = &have_blue_y, out = &(info->blue_y);
- else if (x) have = &have_white_x, out = &(info->white_x);
- else have = &have_white_y, out = &(info->white_y);
- *have = 1 + !!*have;
- *out = (unsigned)atoi(value);
- sprintf(temp, "%u", *out);
- if (strcmp(value, temp))
- bad = 1;
- }
- else if (strstr(line, "Colour space: ") == line)
- {
- have_colourspace = 1 + !!have_colourspace;
- if (!strcmp(value, "sRGB")) info->colourspace = LIBCOOPGAMMA_SRGB;
- else if (!strcmp(value, "RGB")) info->colourspace = LIBCOOPGAMMA_RGB;
- else if (!strcmp(value, "non-RGB")) info->colourspace = LIBCOOPGAMMA_NON_RGB;
- else if (!strcmp(value, "grey")) info->colourspace = LIBCOOPGAMMA_GREY;
- else
- info->colourspace = LIBCOOPGAMMA_UNKNOWN;
- }
- }
-
- (void) next_payload(ctx, &_n);
-
- info->have_gamut = (have_red_x && have_green_x && have_blue_x && have_white_x &&
- have_red_y && have_green_y && have_blue_y && have_white_y);
-
- if (bad || (have_gamma_support != 1) || (have_red_x > 1) || (have_red_y > 1) ||
- (have_green_x > 1) || (have_green_y > 1) || (have_blue_x > 1) || (have_blue_y > 1) ||
- (have_white_x > 1) || (have_white_y > 1) || (have_colourspace > 1))
- {
- errno = EBADMSG;
- copy_errno(ctx);
- return -1;
- }
- if (info->supported != LIBCOOPGAMMA_NO)
- if ((have_cooperative > 1) || (have_depth != 1) || (have_gamma_support != 1) ||
- (have_red_size != 1) || (have_green_size != 1) || (have_blue_size != 1))
- {
- errno = EBADMSG;
- copy_errno(ctx);
- return -1;
- }
-
- return 0;
-}
-
-
-/**
- * Retrieve information about a CRTC:s gamma ramps, synchronous version
- *
- * This is a synchronous request function, as such,
- * you have to ensure that communication is blocking
- * (default), and that there are not asynchronous
- * requests waiting, it also means that EINTR:s are
- * silently ignored and there no wait to cancel the
- * operation without disconnection from the server
- *
- * @param crtc The name of the CRTC
- * @param info Output parameter for the information, must be initialised
- * @param ctx The state of the library, must be connected
- * @return Zero on success, -1 on error, in which case `ctx->error`
- * (rather than `errno`) is read for information about the error
- */
-int libcoopgamma_get_gamma_info_sync(const char* restrict ctrc, libcoopgamma_crtc_info_t* restrict info,
- libcoopgamma_context_t* restrict ctx)
-{
- SYNC_CALL(libcoopgamma_get_gamma_info_send(ctrc, ctx, &async),
- libcoopgamma_get_gamma_info_recv(info, ctx, &async), (copy_errno(ctx), -1));
-}
-
-
-
-/**
- * Retrieve the current gamma ramp adjustments, send request part
- *
- * Cannot be used before connecting to the server
- *
- * @param query The query to send
- * @param ctx The state of the library, must be connected
- * @param async Information about the request, that is needed to
- * identify and parse the response, is stored here
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_get_gamma_send(const libcoopgamma_filter_query_t* restrict query,
- libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wnonnull-compare"
-#endif
- if ((query == NULL) || (query->crtc == NULL) || strchr(query->crtc, '\n'))
- {
- errno = EINVAL;
- goto fail;
- }
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic pop
-#endif
-
- async->message_id = ctx->message_id;
- async->coalesce = query->coalesce;
- SEND_MESSAGE(ctx, NULL, (size_t)0,
- "Command: get-gamma\n"
- "Message ID: %" PRIu32 "\n"
- "CRTC: %s\n"
- "Coalesce: %s\n"
- "High priority: %" PRIi64 "\n"
- "Low priority: %" PRIi64 "\n"
- "\n",
- ctx->message_id, query->crtc, query->coalesce ? "yes" : "no",
- query->high_priority, query->low_priority);
-
- return 0;
- fail:
- copy_errno(ctx);
- return -1;
-}
-
-
-/**
- * Retrieve the current gamma ramp adjustments, receive response part
- *
- * @param table Output for the response, must be initialised
- * @param ctx The state of the library, must be connected
- * @param async Information about the request
- * @return Zero on success, -1 on error, in which case `ctx->error`
- * (rather than `errno`) is read for information about the error
- */
-int libcoopgamma_get_gamma_recv(libcoopgamma_filter_table_t* restrict table,
- libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
- char temp[3 * sizeof(size_t) + 1];
- char* line;
- char* value;
- char* payload;
- size_t i, n, width, clutsize;
- int have_depth = 0;
- int have_red_size = 0;
- int have_green_size = 0;
- int have_blue_size = 0;
- int have_tables = 0;
- int bad = 0, r = 0, g = 0;
-
- if (check_error(ctx, async))
- return -1;
-
- libcoopgamma_filter_table_destroy(table);
-
- for (;;)
- {
- line = next_header(ctx);
- value = strchr(line, ':') + 2;
- if (!*line)
- break;
- else if (strstr(line, "Depth: ") == line)
- {
- have_depth = 1 + !!have_depth;
- if (!strcmp(value, "8")) table->depth = LIBCOOPGAMMA_UINT8;
- else if (!strcmp(value, "16")) table->depth = LIBCOOPGAMMA_UINT16;
- else if (!strcmp(value, "32")) table->depth = LIBCOOPGAMMA_UINT32;
- else if (!strcmp(value, "64")) table->depth = LIBCOOPGAMMA_UINT64;
- else if (!strcmp(value, "f")) table->depth = LIBCOOPGAMMA_FLOAT;
- else if (!strcmp(value, "d")) table->depth = LIBCOOPGAMMA_DOUBLE;
- else
- bad = 1;
- }
- else if (((r = (strstr(line, "Red size: ") == line))) ||
- ((g = (strstr(line, "Green size: ") == line))) ||
- (strstr(line, "Blue size: ") == line))
- {
- size_t* out;
- if (r) have_red_size = 1 + !!have_red_size, out = &(table->red_size);
- else if (g) have_green_size = 1 + !!have_green_size, out = &(table->green_size);
- else have_blue_size = 1 + !!have_blue_size, out = &(table->blue_size);
- *out = (size_t)atol(value);
- sprintf(temp, "%zu", *out);
- if (strcmp(value, temp))
- bad = 1;
- }
- else if (strstr(line, "Tables: ") == line)
- {
- have_tables = 1 + have_tables;
- table->filter_count = (size_t)atol(value);
- sprintf(temp, "%zu", table->filter_count);
- if (strcmp(value, temp))
- bad = 1;
- }
- }
-
- payload = next_payload(ctx, &n);
-
- if (bad || (have_depth != 1) || (have_red_size != 1) || (have_green_size != 1) ||
- (have_blue_size != 1) || (async->coalesce ? (have_tables > 1) : (have_tables == 0)) ||
- (((payload == NULL) || (n == 0)) && (async->coalesce || (table->filter_count > 0))) ||
- ((n > 0) && have_tables && (table->filter_count == 0)) ||
- (async->coalesce && have_tables && (table->filter_count != 1)))
- goto bad;
-
- switch (table->depth)
- {
- case LIBCOOPGAMMA_FLOAT: width = sizeof(float); break;
- case LIBCOOPGAMMA_DOUBLE: width = sizeof(double); break;
- default: INTEGRAL_DEPTHS
- if ((table->depth <= 0) || ((table->depth & 7) != 0))
- goto bad;
- width = (size_t)(table->depth / 8);
- break;
- }
-
- clutsize = table->red_size + table->green_size + table->blue_size;
- clutsize *= width;
-
- if (async->coalesce)
- {
- if (n != clutsize)
- goto bad;
- table->filters = malloc(sizeof(*(table->filters)));
- if (table->filters == NULL)
- goto fail;
- table->filters->priority = 0;
- table->filters->class = NULL;
- table->filters->ramps.u8.red_size = table->red_size;
- table->filters->ramps.u8.green_size = table->green_size;
- table->filters->ramps.u8.blue_size = table->blue_size;
- if (libcoopgamma_ramps_initialise_(&(table->filters->ramps), width) < 0)
- goto fail;
- memcpy(table->filters->ramps.u8.red, payload, clutsize);
- table->filter_count = 1;
- }
- else if (table->filter_count == 0)
- table->filters = NULL;
- else
- {
- size_t off = 0, len;
- table->filters = calloc(table->filter_count, sizeof(*(table->filters)));
- if (table->filters == NULL)
- goto fail;
- for (i = 0; i < table->filter_count; i++)
- {
- if (off + sizeof(int64_t) > n)
- goto bad;
- table->filters[i].priority = *(int64_t*)(payload + off);
- off += sizeof(int64_t);
- if (memchr(payload + off, '\0', n - off) == NULL)
- goto bad;
- len = strlen(payload + off) + 1;
- table->filters[i].class = malloc(len);
- if (table->filters[i].class == NULL)
- goto fail;
- memcpy(table->filters[i].class, payload + off, len);
- off += len;
- if (off + clutsize > n)
- goto bad;
- table->filters[i].ramps.u8.red_size = table->red_size;
- table->filters[i].ramps.u8.green_size = table->green_size;
- table->filters[i].ramps.u8.blue_size = table->blue_size;
- if (libcoopgamma_ramps_initialise_(&(table->filters[i].ramps), width) < 0)
- goto fail;
- memcpy(table->filters->ramps.u8.red, payload + off, clutsize);
- off += clutsize;
- }
- if (off != n)
- goto bad;
- }
-
- return 0;
- bad:
- errno = EBADMSG;
- fail:
- copy_errno(ctx);
- return -1;
-}
-
-
-/**
- * Retrieve the current gamma ramp adjustments, synchronous version
- *
- * This is a synchronous request function, as such,
- * you have to ensure that communication is blocking
- * (default), and that there are not asynchronous
- * requests waiting, it also means that EINTR:s are
- * silently ignored and there no wait to cancel the
- * operation without disconnection from the server
- *
- * @param query The query to send
- * @param table Output for the response, must be initialised
- * @param ctx The state of the library, must be connected
- * @return Zero on success, -1 on error, in which case `ctx->error`
- * (rather than `errno`) is read for information about the error
- */
-int libcoopgamma_get_gamma_sync(const libcoopgamma_filter_query_t* restrict query,
- libcoopgamma_filter_table_t* restrict table,
- libcoopgamma_context_t* restrict ctx)
-{
- SYNC_CALL(libcoopgamma_get_gamma_send(query, ctx, &async),
- libcoopgamma_get_gamma_recv(table, ctx, &async), (copy_errno(ctx), -1));
-}
-
-
-
-/**
- * Apply, update, or remove a gamma ramp adjustment, send request part
- *
- * Cannot be used before connecting to the server
- *
- * @param filter The filter to apply, update, or remove, gamma ramp meta-data must match the CRTC's
- * @param ctx The state of the library, must be connected
- * @param async Information about the request, that is needed to
- * identify and parse the response, is stored here
- * @return Zero on success, -1 on error
- */
-int libcoopgamma_set_gamma_send(const libcoopgamma_filter_t* restrict filter,
- libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
- const void* payload = NULL;
- const char* lifespan;
- char priority[sizeof("Priority: \n") + 3 * sizeof(int64_t)] = {'\0'};
- char length [sizeof("Length: \n") + 3 * sizeof(size_t) ] = {'\0'};
- size_t payload_size = 0, stopwidth = 0;
-
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wnonnull-compare"
-#endif
- if ((filter == NULL) || (filter->crtc == NULL) || strchr(filter->crtc, '\n') ||
- (filter->class == NULL) || strchr(filter->class, '\n'))
- {
- errno = EINVAL;
- goto fail;
- }
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic pop
-#endif
-
- switch (filter->lifespan)
- {
- case LIBCOOPGAMMA_REMOVE: lifespan = "remove"; break;
- case LIBCOOPGAMMA_UNTIL_DEATH: lifespan = "until-death"; break;
- case LIBCOOPGAMMA_UNTIL_REMOVAL: lifespan = "until-removal"; break;
- default:
- errno = EINVAL;
- goto fail;
- }
-
- if (filter->lifespan != LIBCOOPGAMMA_REMOVE)
- {
- switch (filter->depth)
- {
- case LIBCOOPGAMMA_FLOAT: stopwidth = sizeof(float); break;
- case LIBCOOPGAMMA_DOUBLE: stopwidth = sizeof(double); break;
- default: INTEGRAL_DEPTHS
- if ((filter->depth <= 0) || ((filter->depth & 7) != 0))
- {
- errno = EINVAL;
- goto fail;
- }
- stopwidth = (size_t)(filter->depth / 8);
- break;
- }
-
- payload_size = filter->ramps.u8.red_size;
- payload_size += filter->ramps.u8.green_size;
- payload_size += filter->ramps.u8.blue_size;
- payload_size *= stopwidth;
- payload = filter->ramps.u8.red;
- sprintf(priority, "Priority: %" PRIi64 "\n", filter->priority);
- sprintf(length, "Length: %zu\n", payload_size);
- }
-
- async->message_id = ctx->message_id;
- SEND_MESSAGE(ctx, payload, payload_size,
- "Command: set-gamma\n"
- "Message ID: %" PRIu32 "\n"
- "CRTC: %s\n"
- "Class: %s\n"
- "Lifespan: %s\n"
- "%s"
- "%s"
- "\n",
- ctx->message_id, filter->crtc, filter->class, lifespan,
- priority, length);
-
- return 0;
- fail:
- copy_errno(ctx);
- return -1;
-}
-
-
-/**
- * Apply, update, or remove a gamma ramp adjustment, receive response part
- *
- * @param ctx The state of the library, must be connected
- * @param async Information about the request
- * @return Zero on success, -1 on error, in which case `ctx->error`
- * (rather than `errno`) is read for information about the error
- */
-int libcoopgamma_set_gamma_recv(libcoopgamma_context_t* restrict ctx,
- libcoopgamma_async_context_t* restrict async)
-{
- size_t _n = 0;
-
- if (check_error(ctx, async))
- return -(ctx->error.custom || ctx->error.number);
-
- while (*next_header(ctx));
- (void) next_payload(ctx, &_n);
-
- errno = EBADMSG;
- copy_errno(ctx);
- return -1;
-}
-
-
-/**
- * Apply, update, or remove a gamma ramp adjustment, synchronous version
- *
- * This is a synchronous request function, as such,
- * you have to ensure that communication is blocking
- * (default), and that there are not asynchronous
- * requests waiting, it also means that EINTR:s are
- * silently ignored and there no wait to cancel the
- * operation without disconnection from the server
- *
- * @param filter The filter to apply, update, or remove, gamma ramp meta-data must match the CRTC's
- * @param depth The datatype for the stops in the gamma ramps, must match the CRTC's
- * @param ctx The state of the library, must be connected
- * @return Zero on success, -1 on error, in which case `ctx->error`
- * (rather than `errno`) is read for information about the error
- */
-int libcoopgamma_set_gamma_sync(const libcoopgamma_filter_t* restrict filter,
- libcoopgamma_context_t* restrict ctx)
-{
- SYNC_CALL(libcoopgamma_set_gamma_send(filter, ctx, &async),
- libcoopgamma_set_gamma_recv(ctx, &async), (copy_errno(ctx), -1));
-}
-
-
-
-#if defined(__GNUC__)
-# pragma GCC diagnostic pop
-#endif
-
diff --git a/src/test.c b/src/test.c
deleted file mode 100644
index 4a94a42..0000000
--- a/src/test.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/**
- * libcoopgamma -- Library for interfacing with cooperative gamma servers
- * Copyright (C) 2016 Mattias Andrée (maandree@kth.se)
- *
- * This library 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 3 of the License, or
- * (at your option) any later version.
- *
- * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libcoopgamma.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-static int streq(const char* a, const char* b)
-{
- if ((a == NULL) != (b == NULL))
- return 0;
- return (a == NULL) || !strcmp(a, b);
-}
-
-
-static int rampseq(const libcoopgamma_ramps_t* a, const libcoopgamma_ramps_t* b, libcoopgamma_depth_t depth)
-{
- size_t nr, ng, nb, width;
-
- if ((a->u8.red_size != b->u8.red_size) ||
- (a->u8.green_size != b->u8.green_size) ||
- (a->u8.blue_size != b->u8.blue_size))
- return 0;
-
- if (depth == -2)
- width = sizeof(double);
- else if (depth == -1)
- width = sizeof(float);
- else
- width = ((size_t)depth) / 8;
-
- nr = a->u8.red_size * width;
- ng = a->u8.green_size * width;
- nb = a->u8.blue_size * width;
-
- if (memcmp(a->u8.red, b->u8.red, nr + ng + nb))
- return 0;
- if (memcmp(a->u8.green, b->u8.green, ng + nb))
- return 0;
- if (memcmp(a->u8.blue, b->u8.blue, nb))
- return 0;
-
- return 1;
-}
-
-
-int main(void)
-{
- libcoopgamma_filter_t filter1, filter2;
- libcoopgamma_crtc_info_t crtc1, crtc2;
- libcoopgamma_filter_query_t query1, query2;
- libcoopgamma_filter_table_t table1, table2;
- libcoopgamma_context_t ctx1, ctx2;
- libcoopgamma_async_context_t async1, async2;
- size_t n, m, i;
- char* buf;
-
- filter1.priority = INT64_MIN;
- filter1.crtc = "CRTC";
- filter1.class = "A::B::C::D";
- filter1.lifespan = LIBCOOPGAMMA_UNTIL_REMOVAL;
- filter1.depth = LIBCOOPGAMMA_DOUBLE;
- filter1.ramps.d.red_size = 4;
- filter1.ramps.d.green_size = 5;
- filter1.ramps.d.blue_size = 6;
- filter1.ramps.d.red = (double[]){0.0, 0.1, 0.2, 0.5,
- 0.3, 0.11, 0.22, 0.45, 0.9,
- -1, -0.5, 0, 0.5, 1, 1.5};
- filter1.ramps.d.green = filter1.ramps.d.red + filter1.ramps.d.red_size;
- filter1.ramps.d.blue = filter1.ramps.d.green + filter1.ramps.d.green_size;
-
- crtc1.cooperative = 0;
- crtc1.depth = LIBCOOPGAMMA_DOUBLE;
- crtc1.supported = LIBCOOPGAMMA_YES;
- crtc1.red_size = 4;
- crtc1.green_size = 5;
- crtc1.blue_size = 6;
- crtc1.colourspace = LIBCOOPGAMMA_SRGB;
- crtc1.have_gamut = 1;
- crtc1.red_x = 100;
- crtc1.red_y = 50;
- crtc1.green_x = 300;
- crtc1.green_y = 350;
- crtc1.blue_x = 200;
- crtc1.blue_y = 260;
- crtc1.white_x = 500;
- crtc1.white_y = 999;
-
- query1.high_priority = INT64_MIN;
- query1.low_priority = INT64_MIN;
- query1.crtc = "crtc";
- query1.coalesce = 1;
-
- table1.red_size = 4;
- table1.green_size = 5;
- table1.blue_size = 6;
- table1.filter_count = 2;
- table1.filters = (libcoopgamma_queried_filter_t[]){
- {
- .priority = UINT64_MAX,
- .class = "a::b::c",
- .ramps.d = {
- .red_size = 4,
- .green_size = 5,
- .blue_size = 6,
- .red = (double[]){0.0, 0.1, 0.2, 0.5,
- 0.3, 0.11, 0.22, 0.45, 0.9,
- -1, -0.5, 0, 0.5, 1, 1.5}
- }
- }, {
- .priority = UINT64_MAX - 1,
- .class = NULL,
- .ramps.d = {
- .red_size = 4,
- .green_size = 5,
- .blue_size = 6,
- .red = (double[]){0.02, 0.12, 0.22, 0.52,
- 0.32, 0.112, 0.222, 0.452, 0.92,
- -12, -0.52, 0.2, 0.52, 12, 1.52}
- }
- }
- };
- table1.depth = LIBCOOPGAMMA_DOUBLE;
- table1.filters[0].ramps.d.green = table1.filters[0].ramps.d.red + table1.filters[0].ramps.d.red_size;
- table1.filters[1].ramps.d.green = table1.filters[1].ramps.d.red + table1.filters[1].ramps.d.red_size;
- table1.filters[0].ramps.d.blue = table1.filters[0].ramps.d.green + table1.filters[0].ramps.d.green_size;
- table1.filters[1].ramps.d.blue = table1.filters[1].ramps.d.green + table1.filters[1].ramps.d.green_size;
-
- ctx1.error.number = UINT64_MAX;
- ctx1.error.custom = 1;
- ctx1.error.server_side = 0;
- ctx1.error.description = "description";
- ctx1.fd = 3;
- ctx1.have_all_headers = 1;
- ctx1.bad_message = 0;
- ctx1.blocking = 2;
- ctx1.message_id = UINT32_MAX;
- ctx1.in_response_to = UINT32_MAX - 1;
- ctx1.outbound = "0123456789";
- ctx1.outbound_head = 7;
- ctx1.outbound_tail = 2;
- ctx1.outbound_size = 10;
- ctx1.inbound = "abcdefghi";
- ctx1.inbound_head = 6;
- ctx1.inbound_tail = 3;
- ctx1.inbound_size = 9;
- ctx1.length = 100;
- ctx1.curline = 5;
-
- async1.message_id = UINT32_MAX;
- async1.coalesce = 1;
-
- n = libcoopgamma_filter_marshal(&filter1, NULL);
- n += libcoopgamma_crtc_info_marshal(&crtc1, NULL);
- n += libcoopgamma_filter_query_marshal(&query1, NULL);
- n += libcoopgamma_filter_table_marshal(&table1, NULL);
- n += libcoopgamma_context_marshal(&ctx1, NULL);
- n += libcoopgamma_async_context_marshal(&async1, NULL);
-
- buf = malloc(n);
- n = libcoopgamma_filter_marshal(&filter1, buf);
- n += libcoopgamma_crtc_info_marshal(&crtc1, buf + n);
- n += libcoopgamma_filter_query_marshal(&query1, buf + n);
- n += libcoopgamma_filter_table_marshal(&table1, buf + n);
- n += libcoopgamma_context_marshal(&ctx1, buf + n);
- n += libcoopgamma_async_context_marshal(&async1, buf + n);
-
- if (libcoopgamma_filter_unmarshal(&filter2, buf, &m)) return 1; else n = m;
- if (libcoopgamma_crtc_info_unmarshal(&crtc2, buf + n, &m)) return 2; else n += m;
- if (libcoopgamma_filter_query_unmarshal(&query2, buf + n, &m)) return 3; else n += m;
- if (libcoopgamma_filter_table_unmarshal(&table2, buf + n, &m)) return 4; else n += m;
- if (libcoopgamma_context_unmarshal(&ctx2, buf + n, &m)) return 5; else n += m;
- if (libcoopgamma_async_context_unmarshal(&async2, buf + n, &m)) return 6;
- free(buf);
-
- if ((filter1.priority != filter2.priority) ||
- (!streq(filter1.crtc, filter2.crtc)) ||
- (!streq(filter1.class, filter2.class)) ||
- (filter1.lifespan != filter2.lifespan) ||
- (filter1.depth != filter2.depth) ||
- (!rampseq(&(filter1.ramps), &(filter2.ramps), filter1.depth)))
- return 7;
-
- if ((crtc1.cooperative != crtc2.cooperative) ||
- (crtc1.depth != crtc2.depth) ||
- (crtc1.supported != crtc2.supported) ||
- (crtc1.red_size != crtc2.red_size) ||
- (crtc1.green_size != crtc2.green_size) ||
- (crtc1.blue_size != crtc2.blue_size) ||
- (crtc1.colourspace != crtc2.colourspace) ||
- (crtc1.have_gamut != crtc2.have_gamut) ||
- (crtc1.red_x != crtc2.red_x) ||
- (crtc1.red_y != crtc2.red_y) ||
- (crtc1.green_x != crtc2.green_x) ||
- (crtc1.green_y != crtc2.green_y) ||
- (crtc1.blue_x != crtc2.blue_x) ||
- (crtc1.blue_y != crtc2.blue_y) ||
- (crtc1.white_x != crtc2.white_x) ||
- (crtc1.white_y != crtc2.white_y))
- return 8;
-
- if ((query1.high_priority != query2.high_priority) ||
- (query1.low_priority != query2.low_priority) ||
- !streq(query1.crtc, query2.crtc) ||
- (query1.coalesce != query2.coalesce))
- return 9;
-
- if ((table1.red_size != table2.red_size) ||
- (table1.green_size != table2.green_size) ||
- (table1.blue_size != table2.blue_size) ||
- (table1.filter_count != table2.filter_count) ||
- (table1.depth != table2.depth))
- return 10;
- for (i = 0; i < table1.filter_count; i++)
- if ((table1.filters[i].priority != table2.filters[i].priority) ||
- !streq(table1.filters[i].class, table2.filters[i].class) ||
- !rampseq(&(table1.filters[i].ramps), &(table2.filters[i].ramps), table1.depth))
- return 11;
-
- if ((ctx1.error.number != ctx2.error.number) ||
- (ctx1.error.custom != ctx2.error.custom) ||
- (ctx1.error.server_side != ctx2.error.server_side) ||
- !streq(ctx1.error.description, ctx2.error.description))
- return 12;
-
- if ((ctx1.fd != ctx2.fd) ||
- (ctx1.have_all_headers != ctx2.have_all_headers) ||
- (ctx1.bad_message != ctx2.bad_message) ||
- (ctx1.blocking != ctx2.blocking) ||
- (ctx1.message_id != ctx2.message_id) ||
- (ctx1.in_response_to != ctx2.in_response_to) ||
- (ctx1.length != ctx2.length) ||
- (ctx1.curline != ctx2.curline))
- return 13;
-
- if ((ctx2.outbound_head > ctx2.outbound_size) ||
- (ctx2.outbound_tail > ctx2.outbound_size) ||
- (ctx2.inbound_head > ctx2.inbound_size) ||
- (ctx2.inbound_tail > ctx2.inbound_size))
- return 14;
-
- if (((n = ctx1.outbound_head - ctx1.outbound_tail) != ctx2.outbound_head - ctx2.outbound_tail) ||
- ((m = ctx1.inbound_head - ctx1.inbound_tail) != ctx2.inbound_head - ctx2.inbound_tail))
- return 15;
-
- if (memcmp(ctx1.outbound + ctx1.outbound_tail, ctx2.outbound + ctx2.outbound_tail, n) ||
- memcmp(ctx1.inbound + ctx1.inbound_tail, ctx2.inbound + ctx2.inbound_tail, m))
- return 16;
-
- if ((async1.message_id != async2.message_id) ||
- (async1.coalesce != async2.coalesce))
- return 17;
-
- return 0;
-}
-
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..11842c0
--- /dev/null
+++ b/test.c
@@ -0,0 +1,257 @@
+/* See LICENSE file for copyright and license details. */
+#include "libcoopgamma.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static int
+streq(const char *a, const char *b)
+{
+ if (!a != !b)
+ return 0;
+ return !a || !strcmp(a, b);
+}
+
+
+static int
+rampseq(const libcoopgamma_ramps_t *a, const libcoopgamma_ramps_t *b, libcoopgamma_depth_t depth)
+{
+ size_t nr, ng, nb, width;
+
+ if (a->u8.red_size != b->u8.red_size ||
+ a->u8.green_size != b->u8.green_size ||
+ a->u8.blue_size != b->u8.blue_size)
+ return 0;
+
+ if (depth == -2)
+ width = sizeof(double);
+ else if (depth == -1)
+ width = sizeof(float);
+ else
+ width = ((size_t)depth) / 8;
+
+ nr = a->u8.red_size * width;
+ ng = a->u8.green_size * width;
+ nb = a->u8.blue_size * width;
+
+ if (memcmp(a->u8.red, b->u8.red, nr + ng + nb) ||
+ memcmp(a->u8.green, b->u8.green, ng + nb) ||
+ memcmp(a->u8.blue, b->u8.blue, nb))
+ return 0;
+
+ return 1;
+}
+
+
+int
+main(void)
+{
+ libcoopgamma_filter_t filter1, filter2;
+ libcoopgamma_crtc_info_t crtc1, crtc2;
+ libcoopgamma_filter_query_t query1, query2;
+ libcoopgamma_filter_table_t table1, table2;
+ libcoopgamma_context_t ctx1, ctx2;
+ libcoopgamma_async_context_t async1, async2;
+ size_t n, m, i;
+ char* buf;
+
+ filter1.priority = INT64_MIN;
+ filter1.crtc = "CRTC";
+ filter1.class = "A::B::C::D";
+ filter1.lifespan = LIBCOOPGAMMA_UNTIL_REMOVAL;
+ filter1.depth = LIBCOOPGAMMA_DOUBLE;
+ filter1.ramps.d.red_size = 4;
+ filter1.ramps.d.green_size = 5;
+ filter1.ramps.d.blue_size = 6;
+ filter1.ramps.d.red = (double[]){0.0, 0.1, 0.2, 0.5,
+ 0.3, 0.11, 0.22, 0.45, 0.9,
+ -1, -0.5, 0, 0.5, 1, 1.5};
+ filter1.ramps.d.green = filter1.ramps.d.red + filter1.ramps.d.red_size;
+ filter1.ramps.d.blue = filter1.ramps.d.green + filter1.ramps.d.green_size;
+
+ crtc1.cooperative = 0;
+ crtc1.depth = LIBCOOPGAMMA_DOUBLE;
+ crtc1.supported = LIBCOOPGAMMA_YES;
+ crtc1.red_size = 4;
+ crtc1.green_size = 5;
+ crtc1.blue_size = 6;
+ crtc1.colourspace = LIBCOOPGAMMA_SRGB;
+ crtc1.have_gamut = 1;
+ crtc1.red_x = 100;
+ crtc1.red_y = 50;
+ crtc1.green_x = 300;
+ crtc1.green_y = 350;
+ crtc1.blue_x = 200;
+ crtc1.blue_y = 260;
+ crtc1.white_x = 500;
+ crtc1.white_y = 999;
+
+ query1.high_priority = INT64_MIN;
+ query1.low_priority = INT64_MIN;
+ query1.crtc = "crtc";
+ query1.coalesce = 1;
+
+ table1.red_size = 4;
+ table1.green_size = 5;
+ table1.blue_size = 6;
+ table1.filter_count = 2;
+ table1.filters = (libcoopgamma_queried_filter_t[]){
+ {
+ .priority = UINT64_MAX,
+ .class = "a::b::c",
+ .ramps.d = {.red_size = 4,
+ .green_size = 5,
+ .blue_size = 6,
+ .red = (double[]){0.0, 0.1, 0.2, 0.5,
+ 0.3, 0.11, 0.22, 0.45, 0.9,
+ -1, -0.5, 0, 0.5, 1, 1.5}}
+ }, {
+ .priority = UINT64_MAX - 1,
+ .class = NULL,
+ .ramps.d = {.red_size = 4,
+ .green_size = 5,
+ .blue_size = 6,
+ .red = (double[]){0.02, 0.12, 0.22, 0.52,
+ 0.32, 0.112, 0.222, 0.452, 0.92,
+ -12, -0.52, 0.2, 0.52, 12, 1.52}}
+ }
+ };
+ table1.depth = LIBCOOPGAMMA_DOUBLE;
+ table1.filters[0].ramps.d.green = table1.filters[0].ramps.d.red + table1.filters[0].ramps.d.red_size;
+ table1.filters[1].ramps.d.green = table1.filters[1].ramps.d.red + table1.filters[1].ramps.d.red_size;
+ table1.filters[0].ramps.d.blue = table1.filters[0].ramps.d.green + table1.filters[0].ramps.d.green_size;
+ table1.filters[1].ramps.d.blue = table1.filters[1].ramps.d.green + table1.filters[1].ramps.d.green_size;
+
+ ctx1.error.number = UINT64_MAX;
+ ctx1.error.custom = 1;
+ ctx1.error.server_side = 0;
+ ctx1.error.description = "description";
+ ctx1.fd = 3;
+ ctx1.have_all_headers = 1;
+ ctx1.bad_message = 0;
+ ctx1.blocking = 2;
+ ctx1.message_id = UINT32_MAX;
+ ctx1.in_response_to = UINT32_MAX - 1;
+ ctx1.outbound = "0123456789";
+ ctx1.outbound_head = 7;
+ ctx1.outbound_tail = 2;
+ ctx1.outbound_size = 10;
+ ctx1.inbound = "abcdefghi";
+ ctx1.inbound_head = 6;
+ ctx1.inbound_tail = 3;
+ ctx1.inbound_size = 9;
+ ctx1.length = 100;
+ ctx1.curline = 5;
+
+ async1.message_id = UINT32_MAX;
+ async1.coalesce = 1;
+
+ n = libcoopgamma_filter_marshal(&filter1, NULL);
+ n += libcoopgamma_crtc_info_marshal(&crtc1, NULL);
+ n += libcoopgamma_filter_query_marshal(&query1, NULL);
+ n += libcoopgamma_filter_table_marshal(&table1, NULL);
+ n += libcoopgamma_context_marshal(&ctx1, NULL);
+ n += libcoopgamma_async_context_marshal(&async1, NULL);
+
+ buf = malloc(n);
+ n = libcoopgamma_filter_marshal(&filter1, buf);
+ n += libcoopgamma_crtc_info_marshal(&crtc1, &buf[n]);
+ n += libcoopgamma_filter_query_marshal(&query1, &buf[n]);
+ n += libcoopgamma_filter_table_marshal(&table1, &buf[n]);
+ n += libcoopgamma_context_marshal(&ctx1, &buf[n]);
+ n += libcoopgamma_async_context_marshal(&async1, &buf[n]);
+
+ if (libcoopgamma_filter_unmarshal(&filter2, buf, &m)) return 1; else n = m;
+ if (libcoopgamma_crtc_info_unmarshal(&crtc2, &buf[n], &m)) return 2; else n += m;
+ if (libcoopgamma_filter_query_unmarshal(&query2, &buf[n], &m)) return 3; else n += m;
+ if (libcoopgamma_filter_table_unmarshal(&table2, &buf[n], &m)) return 4; else n += m;
+ if (libcoopgamma_context_unmarshal(&ctx2, &buf[n], &m)) return 5; else n += m;
+ if (libcoopgamma_async_context_unmarshal(&async2, &buf[n], &m)) return 6;
+ free(buf);
+
+ if (filter1.priority != filter2.priority ||
+ !streq(filter1.crtc, filter2.crtc) ||
+ !streq(filter1.class, filter2.class) ||
+ filter1.lifespan != filter2.lifespan ||
+ filter1.depth != filter2.depth ||
+ !rampseq(&filter1.ramps, &filter2.ramps, filter1.depth))
+ return 7;
+
+ if (crtc1.cooperative != crtc2.cooperative ||
+ crtc1.depth != crtc2.depth ||
+ crtc1.supported != crtc2.supported ||
+ crtc1.red_size != crtc2.red_size ||
+ crtc1.green_size != crtc2.green_size ||
+ crtc1.blue_size != crtc2.blue_size ||
+ crtc1.colourspace != crtc2.colourspace ||
+ crtc1.have_gamut != crtc2.have_gamut ||
+ crtc1.red_x != crtc2.red_x ||
+ crtc1.red_y != crtc2.red_y ||
+ crtc1.green_x != crtc2.green_x ||
+ crtc1.green_y != crtc2.green_y ||
+ crtc1.blue_x != crtc2.blue_x ||
+ crtc1.blue_y != crtc2.blue_y ||
+ crtc1.white_x != crtc2.white_x ||
+ crtc1.white_y != crtc2.white_y)
+ return 8;
+
+ if (query1.high_priority != query2.high_priority ||
+ query1.low_priority != query2.low_priority ||
+ !streq(query1.crtc, query2.crtc) ||
+ query1.coalesce != query2.coalesce)
+ return 9;
+
+ if (table1.red_size != table2.red_size ||
+ table1.green_size != table2.green_size ||
+ table1.blue_size != table2.blue_size ||
+ table1.filter_count != table2.filter_count ||
+ table1.depth != table2.depth)
+ return 10;
+ for (i = 0; i < table1.filter_count; i++)
+ if (table1.filters[i].priority != table2.filters[i].priority ||
+ !streq(table1.filters[i].class, table2.filters[i].class) ||
+ !rampseq(&table1.filters[i].ramps, &table2.filters[i].ramps, table1.depth))
+ return 11;
+
+ if (ctx1.error.number != ctx2.error.number ||
+ ctx1.error.custom != ctx2.error.custom ||
+ ctx1.error.server_side != ctx2.error.server_side ||
+ !streq(ctx1.error.description, ctx2.error.description))
+ return 12;
+
+ if (ctx1.fd != ctx2.fd ||
+ ctx1.have_all_headers != ctx2.have_all_headers ||
+ ctx1.bad_message != ctx2.bad_message ||
+ ctx1.blocking != ctx2.blocking ||
+ ctx1.message_id != ctx2.message_id ||
+ ctx1.in_response_to != ctx2.in_response_to ||
+ ctx1.length != ctx2.length ||
+ ctx1.curline != ctx2.curline)
+ return 13;
+
+ if (ctx2.outbound_head > ctx2.outbound_size ||
+ ctx2.outbound_tail > ctx2.outbound_size ||
+ ctx2.inbound_head > ctx2.inbound_size ||
+ ctx2.inbound_tail > ctx2.inbound_size)
+ return 14;
+
+ if ((n = ctx1.outbound_head - ctx1.outbound_tail) != ctx2.outbound_head - ctx2.outbound_tail ||
+ (m = ctx1.inbound_head - ctx1.inbound_tail) != ctx2.inbound_head - ctx2.inbound_tail)
+ return 15;
+
+ if (memcmp(ctx1.outbound + ctx1.outbound_tail, ctx2.outbound + ctx2.outbound_tail, n) ||
+ memcmp(ctx1.inbound + ctx1.inbound_tail, ctx2.inbound + ctx2.inbound_tail, m))
+ return 16;
+
+ if (async1.message_id != async2.message_id ||
+ async1.coalesce != async2.coalesce)
+ return 17;
+
+ libcoopgamma_context_destroy(&ctx2, 1);
+ libcoopgamma_filter_destroy(&filter2);
+ libcoopgamma_filter_query_destroy(&query2);
+ libcoopgamma_filter_table_destroy(&table2);
+ return 0;
+}