Compare commits
No commits in common. "devel" and "stable" have entirely different histories.
|
@ -1,6 +0,0 @@
|
|||
*.so
|
||||
*.o
|
||||
*.deb
|
||||
bin/**
|
||||
build/**
|
||||
|
661
LICENSE
661
LICENSE
|
@ -1,661 +0,0 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are 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.
|
||||
|
||||
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.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
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 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 work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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 Affero 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 Affero 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 Affero 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.
|
||||
|
||||
Gem-graph server
|
||||
Copyright (C) 2021 The Gem-Graph Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
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 AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
142
Makefile
142
Makefile
|
@ -1,142 +0,0 @@
|
|||
#=----------------------------------------------------------------------------=#
|
||||
# Makefile #
|
||||
# #
|
||||
# Copyright © 2021 Libre en Communs (contact@a-lec.org) #
|
||||
# Copyright © 2021 Adrien Bourmault (neox@a-lec.org) #
|
||||
# #
|
||||
# This file is part of gem-graph. #
|
||||
# #
|
||||
# This program is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Affero General Public License #
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||
#=----------------------------------------------------------------------------=#
|
||||
|
||||
.PHONY: all clean install run build_system
|
||||
.DELETE_ON_ERROR: $(BINDIR)/gem-graph-server
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
#
|
||||
# Color codes
|
||||
#
|
||||
CL='\033[0;32m'
|
||||
CL2='\033[1;36m'
|
||||
CL3='\033[0m'
|
||||
NC='\033[1;37m'
|
||||
|
||||
#
|
||||
# Variables & constants
|
||||
#
|
||||
NTHREADS= $(shell nproc)
|
||||
|
||||
CC=gcc
|
||||
WARNINGS= -Wall
|
||||
DEBUG= -ggdb -fno-omit-frame-pointer -fdiagnostics-color=always \
|
||||
-fsanitize=bounds -fstack-check -fopenmp \
|
||||
-fsanitize=address \
|
||||
-fsanitize=pointer-compare -fsanitize=pointer-subtract \
|
||||
-fsanitize=leak -fsanitize=undefined -fsanitize=null -fsanitize=bounds
|
||||
OPTIMIZE= -O3
|
||||
INCLUDE= $(shell pkg-config --cflags glib-2.0 libxml-2.0 gtk4)
|
||||
LIBS= $(shell pkg-config --libs glib-2.0 libxml-2.0 gtk4) -lGL -lGLU -lm -lepoxy -lX11 -lGLEW
|
||||
|
||||
BINDIR=bin
|
||||
BUILDDIR=build
|
||||
SRCDIR=src
|
||||
#vpath %.c $(SRCDIR)
|
||||
|
||||
SOURCES= $(shell find $(SRCDIR) -maxdepth 1 -type f -name "*.c")
|
||||
BUILDBINS=$(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
||||
BUILDDEPS=$(patsubst %.c,$(BUILDDIR)/%.d,$(SOURCES))
|
||||
|
||||
|
||||
-include /etc/os-release
|
||||
|
||||
#
|
||||
# Directories
|
||||
#
|
||||
$(BUILDDIR):
|
||||
@mkdir -p $@
|
||||
@echo -e ${CL2}[$@] ${CL}folder generated.${CL3}
|
||||
|
||||
$(BINDIR):
|
||||
@mkdir -p $@
|
||||
@echo -e ${CL2}[$@] ${CL}folder generated.${CL3}
|
||||
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
-include $(BUILDDEPS)
|
||||
|
||||
$(BUILDDIR)/%.d: %.c | $(BUILDDIR)
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@$(CC) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
||||
@echo -e ${CL2}[$@] ${CL}dependencies generated.${CL3}
|
||||
|
||||
#
|
||||
# Compilation
|
||||
#
|
||||
$(BINDIR)/gem-graph-server: $(BUILDBINS) | $(BINDIR)
|
||||
@$(CC) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ $(INCLUDE) $(LIBS)
|
||||
@echo -e ${CL2}[$@] ${CL}built.${CL3}
|
||||
|
||||
|
||||
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@$(CC) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $(INCLUDE) -c $< -o $@
|
||||
@echo -e ${CL2}[$@] ${CL}compiled.${CL3}
|
||||
|
||||
|
||||
#
|
||||
# Virtual recipes
|
||||
#
|
||||
clean:
|
||||
@rm -rf $(BINDIR)
|
||||
@rm -rf $(BUILDDIR)
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
|
||||
install:
|
||||
echo "Installing is not supported"
|
||||
|
||||
build_system:
|
||||
@echo -e ${CL2}[$@] ${CL}building...${CL3}
|
||||
@make $(BINDIR)/gem-graph-server -j $(NTHREADS)
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
|
||||
run: build_system
|
||||
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
||||
@bin/gem-graph-server -C data/config -M data/models -U data/users
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
|
||||
debug: build_system
|
||||
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
||||
@gdb --args $(BINDIR)/gem-graph-server -C data/config -M data/models \
|
||||
-U data/users
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
|
||||
valgrind: build_system
|
||||
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
||||
@valgrind --leak-check=full --show-leak-kinds=all -s \
|
||||
bin/gem-graph-server -C data/config -M data/models -U data/users
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
|
||||
run-both: build_system
|
||||
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
||||
@bin/gem-graph-server -C data/config -M data/models -U data/users\
|
||||
& sleep 1 && bin/gem-graph-ctl
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
run-server: build_system
|
||||
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
||||
@bin/gem-graph-server -C data/config -M data/models -U data/users
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
||||
|
||||
all: build_system
|
||||
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
11
README.md
11
README.md
|
@ -1,13 +1,2 @@
|
|||
# gem-graph-server
|
||||
|
||||
Build & execute the program:
|
||||
```
|
||||
make
|
||||
make run
|
||||
```
|
||||
|
||||
Build & execute tests
|
||||
```
|
||||
make tests
|
||||
make run-tests
|
||||
```
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gem-graph-model version="0.2.1">
|
||||
|
||||
<identity>
|
||||
<name>Modèle de test</name>
|
||||
|
||||
<owner>Léontine Patinette</owner>
|
||||
|
||||
<owner_id>2</owner_id>
|
||||
|
||||
<date>1630000000</date>
|
||||
|
||||
<version>1.0</version>
|
||||
|
||||
<g_ref id="Cause" date="1630000000" author="toujours" lang="en">Ref</g_ref>
|
||||
</identity>
|
||||
|
||||
<parameters id="texte" date="0" author="Léontine Trottine.">
|
||||
<simulation>
|
||||
<max_thread>0</max_thread>
|
||||
<max_cycles>9</max_cycles>
|
||||
|
||||
</simulation>
|
||||
|
||||
<space-param>
|
||||
<!-- loop_on_zero="true" anything moved before zero reenters at the end of space-->
|
||||
<!-- loop_on_zero="false" anything moved before zero is lost-->
|
||||
<!-- loop_on_max="true" anything moved beyond max reenters at the zero of space-->
|
||||
<!-- loop_on_max="false" anything moved beyond max is lost-->
|
||||
|
||||
<dimension x="29"/>
|
||||
|
||||
<!-- Site_multiplicity = number of sites in a space unit. -->
|
||||
<!-- Each site points towards a neighbouring space unit. -->
|
||||
<!-- Several arrows can be stacked in the same site. -->
|
||||
|
||||
<site_multiplicity>2</site_multiplicity>
|
||||
|
||||
</space-param>
|
||||
|
||||
</parameters>
|
||||
|
||||
<!-- Model objects definition -->
|
||||
|
||||
<objects id="only dimers in this model" date="1630000000" author="inanimés,... âme ?">
|
||||
<object id="a dimer" date="1630000000" author="Alphonse">
|
||||
<arrow site="1" weight="1" x="0"/>
|
||||
<arrow site="2" weight="1" x="1"/>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
|
||||
|
||||
<!-- Saved space description (initial space is sequence 0) -->
|
||||
|
||||
<savedstates id="texte" date="1630000000" author="Qui courrait dans l'herbe'">
|
||||
<state id="initial" date="1630000000" author="Une souris verte">
|
||||
<arrow site="0" weight="1" x="0"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
<arrow site="0" weight="1" x="10"/>
|
||||
<arrow site="1" weight="1" x="11"/>
|
||||
<arrow site="0" weight="1" x="20"/>
|
||||
<arrow site="1" weight="1" x="21"/>
|
||||
|
||||
<!-- Three dimers 1-1 are drawn in the global space
|
||||
at locations (0,1) (10,11) and (20,21) -->
|
||||
|
||||
</state>
|
||||
|
||||
</savedstates>
|
||||
|
||||
<!-- Model transitions definition (rules) -->
|
||||
<!-- In this version : <xs:sequence minOccurs="0" maxOccurs="unbounded">-->
|
||||
<!-- Transitions should be edited by hand and written in a 'human-readable' format -->
|
||||
|
||||
<conditions id="random walk of dimers" date="1630000000" author="Zazard le lézard !">
|
||||
|
||||
<condition site="0" weight="1" node_id="1" parent="0" x="0"/>
|
||||
<condition site="1" weight="1" node_id="2" parent="1" x="1"/>
|
||||
<!-- as soon as conditions 1 and 2 are satisfied, a dimer is identified at atation (0,1). -->
|
||||
|
||||
<condition site="0" weight="0" node_id="3" parent="2" x="2"/>
|
||||
<!-- as soon as condition 3 is satisfied,
|
||||
the neighbouring space unit to East of the dimer is empty
|
||||
and the dimer identified by conditions (0,1) can be moved to East. -->
|
||||
|
||||
<condition site="1" weight="0" node_id="4" parent="2" x="-1"/>
|
||||
<!-- as soon as condition 4 is satisfied,
|
||||
the neighbouring space unit to West of the dimer is empty
|
||||
and the dimer identified by conditions (0,1) can be moved to West. -->
|
||||
|
||||
</conditions>
|
||||
|
||||
<transitions>
|
||||
|
||||
<transition id="move_a_dimer_to_east" date="1630000000" author="Pas moi..."
|
||||
parent="3" probability="1">
|
||||
|
||||
<arrow site="1" weight="0" x="0"/>
|
||||
<arrow site="2" weight="0" x="1"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
<arrow site="2" weight="1" x="2"/>
|
||||
|
||||
</transition>
|
||||
|
||||
<transition id="move_a_dimer_to_west" date="1630000000" author="Ni moi !"
|
||||
parent="4" probability="1">
|
||||
|
||||
<arrow site="1" weight="0" x="0"/>
|
||||
<arrow site="2" weight="0" x="1"/>
|
||||
<arrow site="2" weight="1" x="0"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
|
||||
</transition>
|
||||
|
||||
</transitions>
|
||||
|
||||
</gem-graph-model>
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gem-graph-model version="0.2.1">
|
||||
|
||||
<identity>
|
||||
<name>Test 21-03-2023</name>
|
||||
|
||||
<owner>J</owner>
|
||||
|
||||
<owner_id>J</owner_id>
|
||||
|
||||
<date>time_stamp</date>
|
||||
|
||||
<version>1.0</version>
|
||||
|
||||
<g_ref id="Cause" date="time_stamp" author="J" lang="en">Ref</g_ref>
|
||||
</identity>
|
||||
|
||||
<parameters id="texte" date="0" author="J">
|
||||
<simulation>
|
||||
<max_thread>0</max_thread>
|
||||
<max_cycles>9</max_cycles>
|
||||
|
||||
</simulation>
|
||||
|
||||
<space-param>
|
||||
<!-- loop_on_zero="true" anything moved before zero reenters at the end of space-->
|
||||
<!-- loop_on_zero="false" anything moved before zero is lost-->
|
||||
<!-- loop_on_max="true" anything moved beyond max reenters at the zero of space-->
|
||||
<!-- loop_on_max="false" anything moved beyond max is lost-->
|
||||
|
||||
<dimension x="22" y="4" z="8"/>
|
||||
|
||||
<!-- Site_multiplicity = number of sites in a space unit. -->
|
||||
<!-- Each site points towards a neighbouring space unit. -->
|
||||
<!-- Several arrows can be stacked in the same site. -->
|
||||
|
||||
<site_multiplicity>2</site_multiplicity>
|
||||
|
||||
</space-param>
|
||||
|
||||
</parameters>
|
||||
|
||||
<!-- Model objects definition -->
|
||||
|
||||
<objects id="only dimers in this model" date="time_stamp" author="J">
|
||||
<object id="a dimer" date="time_stamp" author="J">
|
||||
<arrow site="1" weight="1" x="0"/>
|
||||
<arrow site="2" weight="1" x="1"/>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
|
||||
|
||||
<!-- Saved space description (initial space is sequence 0) -->
|
||||
|
||||
<savedstates id="texte" date="time_stamp" author="J">
|
||||
<state id="initial" date="time_stamp" author="J">
|
||||
<arrow site="1" weight="1" x="0"/>
|
||||
<arrow site="2" weight="1" x="1"/>
|
||||
<arrow site="1" weight="1" x="10"/>
|
||||
<arrow site="2" weight="1" x="11"/>
|
||||
<arrow site="1" weight="1" x="20"/>
|
||||
<arrow site="2" weight="1" x="21"/>
|
||||
|
||||
<!-- Three dimers 1-1 are drawn in the global space
|
||||
at locations (0,1) (10,11) and (20,21) -->
|
||||
|
||||
</state>
|
||||
|
||||
</savedstates>
|
||||
|
||||
<!-- Model transitions definition (rules) -->
|
||||
<!-- In this version : <xs:sequence minOccurs="0" maxOccurs="unbounded">-->
|
||||
<!-- Transitions should be edited by hand and written in a 'human-readable' format -->
|
||||
|
||||
<conditions_tree>
|
||||
<condition_anonym site="1" weight="1" x="0">
|
||||
<condition_anonym site="2" weight="1" x="1">
|
||||
<condition_anonym site="1" weight="0" x="2">
|
||||
<transition_anonym id="move_a_dimer_to_east"
|
||||
date="time_stamp"
|
||||
author="J"
|
||||
probability="0.5"/>
|
||||
<arrow site="1" weight="0" x="0"/>
|
||||
<arrow site="2" weight="0" x="1"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
<arrow site="2" weight="1" x="2"/>
|
||||
</condition_anonym>
|
||||
<condition_anonym site="2" weight="0" x="-1">
|
||||
<transition_anonym id="move_a_dimer_to_west"
|
||||
date="time_stamp"
|
||||
author="J"
|
||||
probability="0.5"/>
|
||||
<arrow site="1" weight="0" x="0"/>
|
||||
<arrow site="2" weight="0" x="1"/>
|
||||
<arrow site="2" weight="1" x="0"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
</condition_anonym>
|
||||
</condition_anonym>
|
||||
</condition_anonym>
|
||||
</conditions_tree>
|
||||
|
||||
<conditionslist id="random walk of dimers" date="time_stamp" author="J">
|
||||
|
||||
<condition site="1" weight="1" node_id="1" parent="0" x="0"/>
|
||||
<condition site="2" weight="1" node_id="2" parent="1" x="1"/>
|
||||
<!-- as soon as conditions 1 and 2 are satisfied, a dimer is identified at atation (0,1). -->
|
||||
|
||||
<condition site="1" weight="0" node_id="3" parent="2" x="2"/>
|
||||
<!-- as soon as condition 3 is satisfied,
|
||||
the neighbouring space unit to East of the dimer is empty
|
||||
and the dimer identified by conditions (1,2) can be moved to East. -->
|
||||
|
||||
<condition site="2" weight="0" node_id="4" parent="2" x="-1"/>
|
||||
<!-- as soon as condition 4 is satisfied,
|
||||
the neighbouring space unit to West of the dimer is empty
|
||||
and the dimer identified by conditions (1,2) can be moved to West. -->
|
||||
|
||||
</conditionslist>
|
||||
|
||||
<transitionslist>
|
||||
|
||||
<transition id="move_a_dimer_to_east" date="time_stamp" author="J"
|
||||
parent="3" probability="1">
|
||||
|
||||
<arrow site="1" weight="0" x="0"/>
|
||||
<arrow site="2" weight="0" x="1"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
<arrow site="2" weight="1" x="2"/>
|
||||
|
||||
</transition>
|
||||
|
||||
<transition id="move_a_dimer_to_west" date="time_stamp" author="J"
|
||||
parent="4" probability="1">
|
||||
|
||||
<arrow site="1" weight="0" x="0"/>
|
||||
<arrow site="2" weight="0" x="1"/>
|
||||
<arrow site="2" weight="1" x="0"/>
|
||||
<arrow site="1" weight="1" x="1"/>
|
||||
|
||||
</transition>
|
||||
|
||||
</transitionslist>
|
||||
|
||||
</gem-graph-model>
|
|
@ -1,194 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- https://www.freeformatter.com/xml-validator-xsd.html -->
|
||||
<xs:attribute name="id" type="xs:string"/>
|
||||
<xs:attribute name="node_id" type="xs:integer"/>
|
||||
<xs:attribute name="parent" type="xs:integer"/>
|
||||
<xs:attribute name="date" type="xs:integer"/>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="lang" type="xs:string"/>
|
||||
<xs:attribute name="owner" type="xs:string"/>
|
||||
<xs:attribute name="owner_id" type="xs:integer"/>
|
||||
<xs:attribute name="author" type="xs:string"/>
|
||||
<xs:attribute name="version" type="xs:float"/>
|
||||
<xs:attribute name="probability" type="xs:integer"/>
|
||||
<xs:attribute name="site" type="xs:integer" default="0"/>
|
||||
<xs:attribute name="weight" type="xs:integer" default="0"/>
|
||||
<xs:attribute name="u" type="xs:integer"/>
|
||||
<xs:attribute name="v" type="xs:integer"/>
|
||||
<xs:attribute name="w" type="xs:integer"/>
|
||||
<xs:attribute name="x" type="xs:integer"/>
|
||||
<xs:attribute name="y" type="xs:integer"/>
|
||||
<xs:attribute name="z" type="xs:integer"/>
|
||||
<xs:attribute name="t" type="xs:integer"/>
|
||||
|
||||
|
||||
<xs:attributeGroup name="id_date_author">
|
||||
<xs:attribute ref="id"/>
|
||||
<xs:attribute ref="date"/>
|
||||
<xs:attribute ref="author"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:element name="g_ref">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
<xs:attribute ref="lang" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="quote" substitutionGroup="g_ref"/>
|
||||
|
||||
<xs:element name="dimension">
|
||||
<xs:complexType>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="optional"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="arrow">
|
||||
<xs:complexType>
|
||||
<xs:attribute ref="site" use="required"/>
|
||||
<xs:attribute ref="weight" use="required"/>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="optional"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="condition">
|
||||
<xs:complexType>
|
||||
<xs:attribute ref="site" use="required"/>
|
||||
<xs:attribute ref="weight" use="required"/>
|
||||
<xs:attribute ref="node_id" use="required"/>
|
||||
<xs:attribute ref="parent" use="required"/>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="optional"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="state">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element ref="arrow"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="object" substitutionGroup="state"/>
|
||||
|
||||
<xs:element name="transition">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element minOccurs="0" ref="quote"/>
|
||||
<xs:element ref="arrow"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
<xs:attribute ref="parent" use="required"/>
|
||||
<xs:attribute ref="probability" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="gem-graph-model">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="identity">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="name" type="xs:string"/>
|
||||
<xs:element name="owner" type="xs:string"/>
|
||||
<xs:element name="owner_id" type="xs:integer"/>
|
||||
<xs:element name="date" type="xs:integer"/>
|
||||
<xs:element name="version" type="xs:float"/>
|
||||
<xs:element ref="g_ref" minOccurs="1" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="parameters">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
|
||||
<xs:element name="simulation">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="max_thread" type="xs:integer"/>
|
||||
<xs:element name="max_cycles" type="xs:integer"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="space-param">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element ref="dimension"/>
|
||||
<xs:element name="site_multiplicity" type="xs:integer"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="objects">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element ref="object"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="savedstates">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="state"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="conditions">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element minOccurs="0" ref="quote"/>
|
||||
<xs:element ref="condition"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="transitions">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="transition"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:sequence>
|
||||
<xs:attribute ref="version" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- https://www.freeformatter.com/xml-validator-xsd.html -->
|
||||
<xs:attribute name="id" type="xs:string"/>
|
||||
<xs:attribute name="node_id" type="xs:integer"/>
|
||||
<xs:attribute name="parent" type="xs:integer"/>
|
||||
<xs:attribute name="date" type="xs:integer"/>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="lang" type="xs:string"/>
|
||||
<xs:attribute name="owner" type="xs:string"/>
|
||||
<xs:attribute name="owner_id" type="xs:integer"/>
|
||||
<xs:attribute name="author" type="xs:string"/>
|
||||
<xs:attribute name="version" type="xs:float"/>
|
||||
<xs:attribute name="probability" type="xs:integer"/>
|
||||
<xs:attribute name="site" type="xs:integer" default="0"/>
|
||||
<xs:attribute name="weight" type="xs:integer" default="0"/>
|
||||
<xs:attribute name="u" type="xs:integer"/>
|
||||
<xs:attribute name="v" type="xs:integer"/>
|
||||
<xs:attribute name="w" type="xs:integer"/>
|
||||
<xs:attribute name="x" type="xs:integer"/>
|
||||
<xs:attribute name="y" type="xs:integer"/>
|
||||
<xs:attribute name="z" type="xs:integer"/>
|
||||
<xs:attribute name="t" type="xs:integer"/>
|
||||
|
||||
|
||||
<xs:attributeGroup name="id_date_author">
|
||||
<xs:attribute ref="id"/>
|
||||
<xs:attribute ref="date"/>
|
||||
<xs:attribute ref="author"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:element name="g_ref">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
<xs:attribute ref="lang" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="quote" substitutionGroup="g_ref"/>
|
||||
|
||||
<xs:element name="dimension">
|
||||
<xs:complexType>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="optional"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="arrow">
|
||||
<xs:complexType>
|
||||
<xs:attribute ref="site" use="required"/>
|
||||
<xs:attribute ref="weight" use="required"/>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="required"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="condition">
|
||||
<xs:complexType>
|
||||
<xs:attribute ref="site" use="required"/>
|
||||
<xs:attribute ref="weight" use="required"/>
|
||||
<xs:attribute ref="node_id" use="required"/>
|
||||
<xs:attribute ref="parent" use="required"/>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="required"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="condition_anonym">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="condition_anonym"/>
|
||||
</xs:sequence>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="arrow"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute ref="site" use="required"/>
|
||||
<xs:attribute ref="weight" use="required"/>
|
||||
<xs:attribute ref="u" use="optional"/>
|
||||
<xs:attribute ref="v" use="optional"/>
|
||||
<xs:attribute ref="w" use="optional"/>
|
||||
<xs:attribute ref="x" use="required"/>
|
||||
<xs:attribute ref="y" use="optional"/>
|
||||
<xs:attribute ref="z" use="optional"/>
|
||||
<xs:attribute ref="t" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="state">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element ref="arrow"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="object" substitutionGroup="state"/>
|
||||
|
||||
<xs:element name="transition">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element minOccurs="0" ref="quote"/>
|
||||
<xs:element ref="arrow"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
<xs:attribute ref="parent" use="required"/>
|
||||
<xs:attribute ref="probability" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="transition_anonym">
|
||||
<xs:complexType>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
<xs:attribute ref="probability" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="gem-graph-model">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="identity">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="name" type="xs:string"/>
|
||||
<xs:element name="owner" type="xs:string"/>
|
||||
<xs:element name="owner_id" type="xs:integer"/>
|
||||
<xs:element name="date" type="xs:integer"/>
|
||||
<xs:element name="version" type="xs:float"/>
|
||||
<xs:element ref="g_ref" minOccurs="1" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="parameters">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
|
||||
<xs:element name="simulation">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="max_thread" type="xs:integer"/>
|
||||
<xs:element name="max_cycles" type="xs:integer"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="space-param">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="1">
|
||||
<xs:element ref="dimension"/>
|
||||
<xs:element name="site_multiplicity" type="xs:integer"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="objects">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element ref="object"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="savedstates">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="state"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="conditionslist">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element minOccurs="0" ref="quote"/>
|
||||
<xs:element ref="condition"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="id_date_author"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="transitionslist">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="transition"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="conditionstree">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="condition_anonym"/>
|
||||
</xs:sequence>
|
||||
<xs:sequence minOccurs="0" maxOccurs="1">
|
||||
<xs:element ref="transition_anonym"/>
|
||||
</xs:sequence>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element ref="arrow"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:sequence>
|
||||
<xs:attribute ref="version" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Local workers definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Structure describing an arrow
|
||||
*/
|
||||
struct arrow_t {
|
||||
uint load;
|
||||
uint site;
|
||||
uint x;
|
||||
uint y;
|
||||
uint z;
|
||||
|
||||
struct arrow_t *next;
|
||||
struct arrow_t *prev;
|
||||
};
|
||||
|
||||
struct condition_t {
|
||||
uint id;
|
||||
uint load;
|
||||
uint site;
|
||||
uint x;
|
||||
uint y;
|
||||
uint z;
|
||||
|
||||
struct condition_t *child;
|
||||
struct condition_t *parent;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct arrow_t *arrow_new(struct arrow_t *self);
|
||||
|
||||
struct arrow_t *arrow_destroy(struct arrow_t *self);
|
||||
|
||||
struct condition_t *condition_new(struct condition_t *self);
|
||||
|
||||
struct condition_t *condition_destroy(struct condition_t *self);
|
|
@ -1,65 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// base definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <omp.h>
|
||||
#include <math.h>
|
||||
|
||||
#define BASE_H
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define LOGMSG "<%s:%s()>"
|
||||
|
||||
#define printlog(FORMAT, ...) printf("\e[0;36m" LOGMSG "\e[0m" " " FORMAT \
|
||||
"\e[0m", __FILE__,__func__, ##__VA_ARGS__)
|
||||
|
||||
#define printerr(FORMAT,...) fprintf(stderr, "\e[0;31m" LOGMSG "\e[0m" " " \
|
||||
FORMAT "\e[0m", __FILE__,__func__, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct parameters_t
|
||||
{
|
||||
char *configDir;
|
||||
char *userDir;
|
||||
char *modelDir;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server supported commands definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define LINE_LENGTH 80
|
||||
#define LINE_NUMBER 24
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// struct command_t {
|
||||
// const char *name;
|
||||
// char* (*execute)(char*, char**, Server_t*);
|
||||
// const char *help;
|
||||
// } typedef command_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//
|
||||
// Existing commands
|
||||
//
|
||||
// char *Cmd_model(char*, char**, Server_t*);
|
||||
// char *cmd_shutdown(char*, char**, Server_t*);
|
||||
// char *cmd_help(char*, char**, Server_t*);
|
||||
|
||||
// static command_t cmdList[] =
|
||||
// {
|
||||
// {"help", cmd_help, "Help command"},
|
||||
// {"model", cmd_model, "Model command"},
|
||||
// {"shutdown", cmd_shutdown, "Shutdown command"},
|
||||
// };
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
193
include/model.h
193
include/model.h
|
@ -1,193 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Model definitions //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
#include <dirent.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlschemas.h>
|
||||
|
||||
#include "../include/arrows.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define MODEL_STRING_SIZE 64
|
||||
#define MAX_MODEL_NUMBER 1
|
||||
|
||||
#define ARROW_NUMBER 6
|
||||
#define SITE_NUMBER 2
|
||||
#define MAX_CYCLES 10
|
||||
#define MAX_THREAD 0
|
||||
#define XMAX 39
|
||||
#define YMAX 0
|
||||
#define ZMAX 0
|
||||
#define SPACE_SIZE (XMAX+1) * (YMAX+1) * (ZMAX+1)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct space_unit_t
|
||||
{
|
||||
uint id;
|
||||
struct arrow_t *sites[]; // Array of struct arrow_t elements
|
||||
// - lenght is multiplicity
|
||||
};
|
||||
|
||||
struct space_t
|
||||
{
|
||||
// Dimensions of space.
|
||||
int x_dim;
|
||||
int y_dim;
|
||||
int z_dim;
|
||||
|
||||
struct space_unit_t *units; // (flat) arraw of space_unit_t elements :
|
||||
// - lenght is x_dim * y_dim * z_dim
|
||||
// - access to the (x,y,z) is done by
|
||||
// units[ x
|
||||
// + dim_x * y
|
||||
// + dim_x * dim_y * z ]
|
||||
};
|
||||
|
||||
struct state_t
|
||||
{
|
||||
// Metadata
|
||||
char id[25];
|
||||
int owner_id;
|
||||
time_t date;
|
||||
|
||||
struct space_t *space;
|
||||
struct arrow_t *arrows;
|
||||
};
|
||||
|
||||
struct model_t
|
||||
{
|
||||
// Metadata
|
||||
char id;
|
||||
int owner_id;
|
||||
time_t date;
|
||||
union version
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
};
|
||||
|
||||
// XML handlers
|
||||
xmlDocPtr doc;
|
||||
xmlHashTablePtr hashtable;
|
||||
|
||||
// User friendly metadata
|
||||
char *owner_name;
|
||||
char *model_name;
|
||||
char *filename;
|
||||
|
||||
// Model parameters
|
||||
int multiplicity; // number of sites in a space_unit
|
||||
int dimension; // number of space dimensions
|
||||
|
||||
// Simulation parameters
|
||||
int max_thread;
|
||||
int max_cycles;
|
||||
|
||||
// Handler to the current space of the model
|
||||
struct space_t *space;
|
||||
|
||||
// Handler to the conditions
|
||||
struct condition_t *conditions;
|
||||
|
||||
// Handler to the arrows
|
||||
struct arrow_t *arrows;
|
||||
size_t n_arrows;
|
||||
|
||||
// Handler to the saved states array
|
||||
struct state_t *states;
|
||||
size_t n_states;
|
||||
|
||||
struct model_t *next;
|
||||
struct model_t *prev;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Model init function (and model discovery) //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void model_system_init (struct parameters_t *parameters);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Model stopping function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void model_system_shutdown (void);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Load a model ready to execute //
|
||||
// -------------------------------------------------------------------------- //
|
||||
bool model_load (struct model_t *self);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Unload a model //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// int model_unload (int id);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Add a model to the known model list //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// void model_add_to_known (model_t **newModel);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Print informations about all models (known and loaded) to the client //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// void print_models (char *buf);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Launch a model execution //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// int model_run (int id);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Stop a model execution //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// int model_stop (int id);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Stop and unload all loaded or running model //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// void model_shutdown (void);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Parsing primitives //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
char model_get_dim(struct model_t *self);
|
||||
|
||||
long model_get_dim_value(struct model_t *self, const char *axis);
|
||||
|
||||
char model_get_multiplicity(struct model_t *self);
|
||||
|
||||
bool model_get_next_state(struct model_t *self, char *new_state_id);
|
||||
|
||||
bool model_get_next_arrow(struct model_t *self,
|
||||
struct arrow_t *new_arrow,
|
||||
const char *state_id,
|
||||
char dimension);
|
|
@ -1,98 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Scheduler definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include "../include/worker.h"
|
||||
#include "../include/model.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
enum
|
||||
{
|
||||
// quitting values
|
||||
SCHED_NORMAL_EXIT,
|
||||
SCHED_OMP_ERROR,
|
||||
SCHED_UNKNOWN_ERROR,
|
||||
|
||||
// non-quitting / non-fatal errors
|
||||
SCHED_NON_FATAL_ERRORS, //meta-code
|
||||
SCHED_MODEL_ERROR,
|
||||
|
||||
SCHED_CONTINUE
|
||||
};
|
||||
|
||||
struct scheduler_t
|
||||
{
|
||||
int id;
|
||||
int n_workers;
|
||||
int pleaseStop;
|
||||
|
||||
struct model_t **models;
|
||||
struct worker_t **workers;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler main function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
int sched_start (struct scheduler_t *scheduler, struct parameters_t *parameters);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler content destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// static inline void sched_clean (scheduler_t *scheduler)
|
||||
// {
|
||||
// assert(scheduler);
|
||||
|
||||
// if (scheduler->globalDrawingSpace) {
|
||||
// if (scheduler->globalDrawingSpace->space) {
|
||||
// free(scheduler->globalDrawingSpace->space);
|
||||
// scheduler->globalDrawingSpace->space = NULL;
|
||||
// }
|
||||
// free(scheduler->globalDrawingSpace);
|
||||
// scheduler->globalDrawingSpace = NULL;
|
||||
// }
|
||||
|
||||
// if (scheduler->arrowArray) {
|
||||
// if (scheduler->arrowArray->array) {
|
||||
// free(scheduler->arrowArray->array);
|
||||
// scheduler->arrowArray->array = NULL;
|
||||
// }
|
||||
// free(scheduler->arrowArray);
|
||||
// scheduler->arrowArray = NULL;
|
||||
// }
|
||||
// }
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// static inline void sched_shutdown (scheduler_t *scheduler)
|
||||
// {
|
||||
// assert(scheduler);
|
||||
// free(scheduler);
|
||||
// scheduler = NULL;
|
||||
// }
|
|
@ -1,40 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Server init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
//void server_init (server_t *server);
|
|
@ -1,41 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Supervisor definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Supervisor init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
//void superv_init (supervisor_t *supervisor);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Supervisor destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// static inline void superv_destroy (supervisor_t *supervisor)
|
||||
// {
|
||||
// ;
|
||||
// }
|
|
@ -1,181 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Terminal management tools //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define C_CLEARSCREEN "\e[2J"
|
||||
#define C_CLEARLINE "\e[2K"
|
||||
#define C_CURSORLEFT "\e[1D"
|
||||
#define C_CURSORRIGHT "\e[1C"
|
||||
#define C_SAVE_CURSORPOS "\e7"
|
||||
#define C_RESTORE_CURSORPOS "\e8"
|
||||
#define C_COLOR_RED "\e[01;31m"
|
||||
#define C_COLOR_YELLOW "\e[00;33m"
|
||||
#define C_COLOR_GREEN "\e[00;32m"
|
||||
#define C_COLOR_BLUE "\e[01;34m"
|
||||
#define C_COLOR_REVERSE "\e[7m"
|
||||
#define C_COLOR_NORMAL "\e[0m"
|
||||
#define C_COLOR_BLACK_ON_GREEN "\e[30;42m"
|
||||
#define C_COLOR_LIGHTWHITE_ON_GREEN "\e[47;42m"
|
||||
#define C_COLOR_LIGHTWHITE_ON_GREY "\e[47;100m"
|
||||
#define C_COLOR_BLACK_ON_LIGHTGREY "\e[30;102m"
|
||||
#define C_COLOR_WHITE_ON_BLUE "\e[107;44m"
|
||||
|
||||
#define NON_BLOCKING 1
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
volatile struct winsize termWinSize;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Get a character code from the keyboard //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline int term_getch(bool nonBlocking)
|
||||
{
|
||||
int buf = 0;
|
||||
// old terminal
|
||||
struct termios old = {0};
|
||||
|
||||
// force flush stdout
|
||||
fflush(stdout);
|
||||
|
||||
// Set non-blocking mode if asked
|
||||
if(nonBlocking)
|
||||
fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
|
||||
if(tcgetattr(0, &old) < 0) {
|
||||
printErr("%sError getting terminal settings! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
old.c_lflag &= ~ICANON; // disable buffered I/O
|
||||
old.c_lflag &= ~ECHO; // set no echo mode
|
||||
|
||||
if(tcsetattr(0, TCSANOW, &old) < 0) {
|
||||
printErr("%sError setting terminal settings! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = getchar();
|
||||
if(buf < 0) {
|
||||
// Check target busy (try again)
|
||||
if(errno == EAGAIN)
|
||||
return 0;
|
||||
|
||||
printErr("%sError reading character! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
old.c_lflag |= ICANON; // enable buffered I/O
|
||||
old.c_lflag |= ECHO; // set echo mode
|
||||
|
||||
if(tcsetattr(0, TCSADRAIN, &old) < 0) {
|
||||
printErr("%sError resetting terminal settings! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Reset blocking mode
|
||||
if(nonBlocking)
|
||||
fcntl(0, F_SETFL, 0);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Get the screen size //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_get_screensize(int signum)
|
||||
{
|
||||
// Get current terminal size
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &termWinSize);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Set cursor location //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_set_cursor_location(char x, char y)
|
||||
{
|
||||
printf("\x1b[%d;%dH", y, x);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Save cursor location //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_save_cursor_location(void)
|
||||
{
|
||||
printf(C_SAVE_CURSORPOS);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Restore cursor location //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_restore_cursor_location(void)
|
||||
{
|
||||
printf(C_RESTORE_CURSORPOS);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Move cursor location to the right //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_move_cursor_forward(void)
|
||||
{
|
||||
printf(C_CURSORRIGHT);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Move cursor location to the left //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_move_cursor_backward(void)
|
||||
{
|
||||
printf(C_CURSORLEFT);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Clear screen //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void term_clear_screen(void)
|
||||
{
|
||||
printf(C_CLEARSCREEN);
|
||||
term_set_cursor_location(1,1);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Local workers definition //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
#include "../include/scheduler.h"
|
||||
#include "../include/arrows.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
enum
|
||||
{
|
||||
// quitting values
|
||||
WORKER_NORMAL_EXIT,
|
||||
WORKER_OMP_ERROR,
|
||||
WORKER_UNKNOWN_ERROR,
|
||||
|
||||
// non-quitting / non-fatal errors
|
||||
WORKER_NON_FATAL_ERRORS, //meta-code
|
||||
WORKER_MODEL_ERROR,
|
||||
|
||||
WORKER_CONTINUE
|
||||
};
|
||||
|
||||
struct scheduler_t;
|
||||
|
||||
struct worker_t
|
||||
{
|
||||
int id;
|
||||
int thread_num;
|
||||
int status;
|
||||
|
||||
struct arrow_t *elected_arrow;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Worker init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void worker_start(struct worker_t *self, struct scheduler_t *scheduler);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Worker destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
// static inline void worker_destroy(worker_t *worker)
|
||||
// {
|
||||
// worker->pleaseStop = false;
|
||||
// worker->terminated = false;
|
||||
// worker->returnValue = false;
|
||||
|
||||
// worker->id = 0;
|
||||
// free(worker->localWorkAreaCenter);
|
||||
// worker->localWorkAreaCenter = NULL;
|
||||
// }
|
27
manifest.scm
27
manifest.scm
|
@ -1,27 +0,0 @@
|
|||
;;
|
||||
;; Dépendances sous GNU Guix
|
||||
;;
|
||||
|
||||
|
||||
(specifications->manifest
|
||||
(list
|
||||
"bash"
|
||||
"coreutils"
|
||||
"gcc-toolchain"
|
||||
"pkg-config"
|
||||
"valgrind"
|
||||
"findutils"
|
||||
"gdb"
|
||||
"make"
|
||||
"libxml2"
|
||||
"glu"
|
||||
"glew"
|
||||
"glfw"
|
||||
"cglm"
|
||||
"libepoxy"
|
||||
"glib"
|
||||
"mesa-headers"
|
||||
"mesa"
|
||||
"libomp"
|
||||
)
|
||||
)
|
91
src/arrows.c
91
src/arrows.c
|
@ -1,91 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Arrows management module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/arrows.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct arrow_t *arrow_new(struct arrow_t *self)
|
||||
{
|
||||
if (self == NULL) {
|
||||
return calloc (1, sizeof(struct arrow_t));
|
||||
}
|
||||
|
||||
self->next = calloc (1, sizeof(struct arrow_t));
|
||||
self->next->prev = self;
|
||||
|
||||
return self->next;
|
||||
}
|
||||
|
||||
struct arrow_t *arrow_destroy(struct arrow_t *self)
|
||||
{
|
||||
struct arrow_t *res = NULL;
|
||||
|
||||
if (self->next)
|
||||
if (self->prev) {
|
||||
self->prev->next = self->next;
|
||||
} else {
|
||||
res = self->next;
|
||||
self->next->prev = NULL;
|
||||
}
|
||||
|
||||
if (self->prev)
|
||||
if (self->next) {
|
||||
self->next->prev = self->prev;
|
||||
} else {
|
||||
res = self->prev;
|
||||
self->prev->next = NULL;
|
||||
}
|
||||
|
||||
free(self);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct condition_t *condition_new(struct condition_t *self)
|
||||
{
|
||||
if (self == NULL) {
|
||||
return calloc (1, sizeof(struct condition_t));
|
||||
}
|
||||
|
||||
self->child = calloc (1, sizeof(struct condition_t));
|
||||
self->child->parent = self;
|
||||
|
||||
return self->child;
|
||||
}
|
||||
|
||||
struct condition_t *condition_destroy(struct condition_t *self)
|
||||
{
|
||||
struct condition_t *res = NULL;
|
||||
|
||||
if (self->child) {
|
||||
condition_destroy(self->child);
|
||||
}
|
||||
|
||||
if (self->parent)
|
||||
self->parent->child = NULL;
|
||||
|
||||
free(self);
|
||||
|
||||
return res;
|
||||
}
|
480
src/cli/cli.c
480
src/cli/cli.c
|
@ -1,480 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Command line interface main file //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/terminal.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define SEND_BUFFER_SIZE 80
|
||||
#define RECEIVE_BUFFER_SIZE 80 * 24
|
||||
#define NHISTORY 25
|
||||
|
||||
#define SERVER_IP_ADDR "127.0.0.1"
|
||||
#define SERVER_PORT 9000
|
||||
|
||||
#define KEY_ESCAPE_1 27
|
||||
#define KEY_ESCAPE_2 91
|
||||
#define KEY_ESCAPE_3 51
|
||||
#define KEY_ARROW_UP 65 // accessible after sequence KEY_ESCAPE_1, 2
|
||||
#define KEY_ARROW_DOWN 66 // accessible after sequence KEY_ESCAPE_1, 2
|
||||
#define KEY_ARROW_RIGHT 67 // accessible after sequence KEY_ESCAPE_1, 2
|
||||
#define KEY_ARROW_LEFT 68 // accessible after sequence KEY_ESCAPE_1, 2
|
||||
#define KEY_BACKSPACE 127
|
||||
#define KEY_DELETE 126 // accessible after sequence KEY_ESCAPE_1, 2, 3
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//
|
||||
// Print monitor screen
|
||||
//
|
||||
void CliDecorateMonitor(int signum)
|
||||
{
|
||||
const char titleText[] = "GEM-GRAPH MONITOR";
|
||||
const char screenTitleText[] = "Model view";
|
||||
const char infosTitleText[] = "Model informations";
|
||||
|
||||
const char infosNameText[] = "Name ";
|
||||
const char infosStatusText[] = "Status ";
|
||||
const char infosOwnerText[] = "Owner ";
|
||||
const char infosSchedulerText[] = "Scheduler id";
|
||||
const char infosScThreadsText[] = "+ threads ";
|
||||
|
||||
TermGetScreenSize(signum);
|
||||
|
||||
TermClearScreen();
|
||||
|
||||
TermSetCursorLocation(1,1);
|
||||
printf(C_COLOR_NORMAL C_COLOR_WHITE_ON_BLUE);
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
TermSetCursorLocation(1,1);
|
||||
printf("%s%s",
|
||||
C_COLOR_NORMAL C_COLOR_WHITE_ON_BLUE,
|
||||
titleText
|
||||
);
|
||||
|
||||
TermSetCursorLocation(1,2);
|
||||
printf(C_COLOR_NORMAL C_COLOR_BLACK_ON_GREEN);
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
TermSetCursorLocation(1,2);
|
||||
printf("%s%s",
|
||||
C_COLOR_NORMAL C_COLOR_BLACK_ON_GREEN,
|
||||
screenTitleText
|
||||
);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 2);
|
||||
printf("%s%s",
|
||||
C_COLOR_NORMAL C_COLOR_BLACK_ON_GREEN,
|
||||
infosTitleText
|
||||
);
|
||||
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 4);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_NORMAL C_COLOR_BLACK_ON_LIGHTGREY,
|
||||
infosNameText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 6);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_GREEN,
|
||||
infosStatusText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 8);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_LIGHTGREY,
|
||||
infosOwnerText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 10);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_GREEN,
|
||||
infosSchedulerText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 12);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_LIGHTGREY,
|
||||
infosScThreadsText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
|
||||
TermSetCursorLocation(1, TermWindowSize.ws_row - 1);
|
||||
printf(C_COLOR_NORMAL C_COLOR_WHITE_ON_BLUE);
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
TermSetCursorLocation(1, TermWindowSize.ws_row);
|
||||
printf(C_COLOR_NORMAL);
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
TermSetCursorLocation(1, TermWindowSize.ws_row);
|
||||
printf("%sQ%s Quit\t%sS%s Start/Stop",
|
||||
C_COLOR_NORMAL C_COLOR_REVERSE,
|
||||
C_COLOR_NORMAL,
|
||||
C_COLOR_REVERSE,
|
||||
C_COLOR_NORMAL);
|
||||
|
||||
TermSetCursorLocation(1, 3);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
//
|
||||
// Monitor mode main loop
|
||||
//
|
||||
int CliConnectedMonitor(int sockfd)
|
||||
{
|
||||
char sendBuff[SEND_BUFFER_SIZE] = {0};
|
||||
char receiveBuff[RECEIVE_BUFFER_SIZE] = {0};
|
||||
|
||||
int pleaseStop = 0;
|
||||
|
||||
char curChar;
|
||||
int answerLength;
|
||||
|
||||
signal(SIGWINCH ,CliDecorateMonitor);
|
||||
CliDecorateMonitor(0);
|
||||
|
||||
while (!pleaseStop) {
|
||||
// Zeroing buffer
|
||||
bzero(sendBuff, sizeof(sendBuff));
|
||||
|
||||
// Read command from terminal
|
||||
curChar = TermGetch(NON_BLOCKING);
|
||||
|
||||
switch (curChar) {
|
||||
case 'q':
|
||||
pleaseStop = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* // Otherwise send command to server */
|
||||
/* send(sockfd, sendBuff, sizeof(sendBuff), 0); */
|
||||
|
||||
/* // Zeroing buffer */
|
||||
/* bzero(receiveBuff, sizeof(receiveBuff)); */
|
||||
|
||||
/* // Reading server answer */
|
||||
/* answerLength = recv(sockfd, receiveBuff, sizeof(receiveBuff), 0); */
|
||||
|
||||
/* // Detect disconnection */
|
||||
/* if (answerLength == 0) { */
|
||||
/* break; */
|
||||
/* } */
|
||||
|
||||
/* // Detect null-string returned */
|
||||
/* if (receiveBuff[0] == '\0') { */
|
||||
/* // Invalid command */
|
||||
/* } */
|
||||
}
|
||||
TermClearScreen();
|
||||
printf("%sEnd of monitoring session\n\e[0m", C_COLOR_YELLOW);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Main CLI loop
|
||||
//
|
||||
void CliConnectedCommandLine(int sockfd)
|
||||
{
|
||||
char sendBuff[SEND_BUFFER_SIZE] = {0};
|
||||
char receiveBuff[RECEIVE_BUFFER_SIZE] = {0};
|
||||
|
||||
char historyBuff[SEND_BUFFER_SIZE * NHISTORY + 1] = {0};
|
||||
int historyIndex = 0, historyModifier;
|
||||
|
||||
char curChar;
|
||||
int curLineLength, curPosition, continueReadLine, answerLength,
|
||||
promptLength;
|
||||
|
||||
const char *exitCommand = "exit";
|
||||
const char *monitorCommand = "monitor";
|
||||
const char *promptString = C_COLOR_BLUE "gem-graph console" C_COLOR_NORMAL "> ";
|
||||
|
||||
promptLength = strlen("gem-graph console");
|
||||
|
||||
for (;;) {
|
||||
// Zeroing buffer
|
||||
bzero(sendBuff, sizeof(sendBuff));
|
||||
printf("%s", promptString);
|
||||
|
||||
// Read command from terminal
|
||||
curLineLength = 0;
|
||||
curPosition = 0;
|
||||
continueReadLine = 1;
|
||||
historyModifier = -1;
|
||||
while (continueReadLine && (curChar = TermGetch(0))) {
|
||||
|
||||
switch (curChar) {
|
||||
|
||||
case '\n':
|
||||
printf("%c", curChar);
|
||||
continueReadLine = 0;
|
||||
break;
|
||||
|
||||
case KEY_BACKSPACE:
|
||||
if (strlen(sendBuff) == 0)
|
||||
break;
|
||||
|
||||
// Delete last char
|
||||
sendBuff[--curPosition] = 0;
|
||||
curLineLength--;
|
||||
|
||||
if (curLineLength >= 0) {
|
||||
|
||||
TermSaveCursorLocation();
|
||||
|
||||
memmove(sendBuff + curPosition, sendBuff + curPosition + 1,
|
||||
SEND_BUFFER_SIZE);
|
||||
|
||||
printf("%s\r%s%s",
|
||||
C_CLEARLINE,
|
||||
promptString,
|
||||
sendBuff
|
||||
);
|
||||
|
||||
TermRestoreCursorLocation();
|
||||
TermMoveCursorBackward();
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_ESCAPE_1:
|
||||
if (TermGetch(0) == KEY_ESCAPE_2) {
|
||||
|
||||
switch(TermGetch(0)) {
|
||||
|
||||
case KEY_ARROW_UP:
|
||||
if (historyIndex <= 0)
|
||||
break;
|
||||
historyModifier = (historyModifier + 1)
|
||||
% (historyIndex + 1);
|
||||
printf("%s\r%s%s",
|
||||
C_CLEARLINE,
|
||||
promptString,
|
||||
&historyBuff[
|
||||
(historyIndex - historyModifier - 1)
|
||||
* SEND_BUFFER_SIZE
|
||||
]
|
||||
);
|
||||
memcpy(sendBuff, &historyBuff[
|
||||
(historyIndex - historyModifier - 1)
|
||||
* SEND_BUFFER_SIZE
|
||||
], SEND_BUFFER_SIZE);
|
||||
curLineLength = strlen(sendBuff);
|
||||
curPosition = curLineLength;
|
||||
break;
|
||||
|
||||
case KEY_ARROW_DOWN:
|
||||
if (historyIndex <= 0)
|
||||
break;
|
||||
historyModifier = (historyModifier + historyIndex)
|
||||
% (historyIndex + 1);
|
||||
printf("%s\r%s%s",
|
||||
C_CLEARLINE,
|
||||
promptString,
|
||||
&historyBuff[
|
||||
(historyIndex - historyModifier - 1)
|
||||
* SEND_BUFFER_SIZE
|
||||
]
|
||||
);
|
||||
memcpy(sendBuff, &historyBuff[
|
||||
(historyIndex - historyModifier - 1)
|
||||
* SEND_BUFFER_SIZE
|
||||
], SEND_BUFFER_SIZE);
|
||||
curLineLength = strlen(sendBuff);
|
||||
curPosition = curLineLength;
|
||||
break;
|
||||
|
||||
case KEY_ARROW_LEFT:
|
||||
if (curPosition > 0) {
|
||||
TermMoveCursorBackward();
|
||||
curPosition--;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_ARROW_RIGHT:
|
||||
if (curPosition < curLineLength) {
|
||||
TermMoveCursorForward();
|
||||
curPosition++;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_ESCAPE_3:
|
||||
if (TermGetch(0) == KEY_DELETE) {
|
||||
if (strlen(sendBuff) == 0)
|
||||
break;
|
||||
|
||||
// Delete next char
|
||||
sendBuff[curPosition] = 0;
|
||||
curLineLength--;
|
||||
|
||||
if (curLineLength >= 0) {
|
||||
|
||||
TermSaveCursorLocation();
|
||||
|
||||
memmove(sendBuff + curPosition, sendBuff + curPosition + 1,
|
||||
SEND_BUFFER_SIZE);
|
||||
|
||||
printf("%s\r%s%s",
|
||||
C_CLEARLINE,
|
||||
promptString,
|
||||
sendBuff
|
||||
);
|
||||
|
||||
TermRestoreCursorLocation();
|
||||
}
|
||||
else {
|
||||
TermMoveCursorForward(); // XXX
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (curLineLength < MIN(SEND_BUFFER_SIZE,
|
||||
TermWindowSize.ws_col - promptLength - 3)
|
||||
&& curChar > 0) {
|
||||
TermSaveCursorLocation();
|
||||
|
||||
memmove(sendBuff + curPosition + 1, sendBuff + curPosition,
|
||||
SEND_BUFFER_SIZE);
|
||||
|
||||
sendBuff[curPosition++] = curChar;
|
||||
curLineLength++;
|
||||
|
||||
printf("%s\r%s%s",
|
||||
C_CLEARLINE,
|
||||
promptString,
|
||||
sendBuff
|
||||
);
|
||||
|
||||
TermRestoreCursorLocation();
|
||||
TermMoveCursorForward();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
// Do not send null-string
|
||||
if (curLineLength == 0)
|
||||
continue;
|
||||
|
||||
// Update history
|
||||
memcpy(&historyBuff[historyIndex * SEND_BUFFER_SIZE], sendBuff,
|
||||
SEND_BUFFER_SIZE);
|
||||
historyIndex = (historyIndex + 1) % NHISTORY;
|
||||
|
||||
// Quit if asked
|
||||
if (strcmp(exitCommand, sendBuff) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Launch monitor mode if asked
|
||||
if (strcmp(monitorCommand, sendBuff) == 0) {
|
||||
CliConnectedMonitor(sockfd);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise send command to server
|
||||
send(sockfd, sendBuff, sizeof(sendBuff), 0);
|
||||
|
||||
// Zeroing buffer
|
||||
bzero(receiveBuff, sizeof(receiveBuff));
|
||||
|
||||
// Reading server answer
|
||||
answerLength = recv(sockfd, receiveBuff, sizeof(receiveBuff), 0);
|
||||
|
||||
// Detect disconnection
|
||||
if (answerLength == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Detect null-string returned
|
||||
if (receiveBuff[0] == '\0') {
|
||||
printf("%sInvalid command!\n\e[0m", C_COLOR_YELLOW);
|
||||
}
|
||||
|
||||
printf("%s\n", receiveBuff);
|
||||
}
|
||||
printf("%sDisconnected\n\e[0m", C_COLOR_YELLOW);
|
||||
}
|
||||
|
||||
//
|
||||
// main
|
||||
//
|
||||
int main(void)
|
||||
{
|
||||
int sockfd;
|
||||
struct sockaddr_in servaddr;
|
||||
|
||||
// Socket creation
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd == -1) {
|
||||
printErr("%sSocket creation failed! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
bzero(&servaddr, sizeof(servaddr));
|
||||
|
||||
// Assign IP, PORT
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = inet_addr(SERVER_IP_ADDR);
|
||||
servaddr.sin_port = htons(SERVER_PORT);
|
||||
|
||||
// Connect to the server
|
||||
if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) != 0) {
|
||||
printErr("%sConnection failed! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return 2;
|
||||
}
|
||||
|
||||
printLog("%sConnected to server!\n\n", C_COLOR_GREEN);
|
||||
|
||||
signal(SIGWINCH, TermGetScreenSize);
|
||||
TermGetScreenSize(0);
|
||||
|
||||
CliConnectedCommandLine(sockfd);
|
||||
|
||||
// close the socket
|
||||
close(sockfd);
|
||||
|
||||
return 0;
|
||||
}
|
223
src/cmds.c
223
src/cmds.c
|
@ -1,223 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server management module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/cmds.h"
|
||||
#include "../include/scheduler.h"
|
||||
#include "../include/model.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* char *cmd_model(char *buf, char **argv, server_t *args) */
|
||||
/* { */
|
||||
/* int id, eid; */
|
||||
/* model_t *newModel; */
|
||||
|
||||
/* // invalid use */
|
||||
/* if (!argv[1]) { */
|
||||
/* strcat(buf, "{create | delete | load | unload | run | stop | list |" */
|
||||
/* "info}\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* if (strcmp(argv[1], "create") == 0) { */
|
||||
|
||||
/* if (!argv[2] || !argv[3]) { */
|
||||
/* goto createEnd; */
|
||||
/* } */
|
||||
|
||||
/* if (strncmp(argv[2], "name=", 5) == 0) { */
|
||||
|
||||
/* if (strncmp(argv[3], "file=", 5) == 0) { */
|
||||
/* // TODO get the file content (sent by the client) from args */
|
||||
|
||||
/* // Creating model */
|
||||
/* //XXX ModelAddToKnown(&newModel); */
|
||||
|
||||
/* // TODO modify model according to things in file */
|
||||
|
||||
/* // Write name */
|
||||
/* strcpy(newModel->name, argv[2] + 5); */
|
||||
|
||||
/* // Write filename */
|
||||
/* strcpy(newModel->filename, argv[3] + 5); */
|
||||
|
||||
/* sprintf(buf + strlen(buf), "Model %s created with id %d\n", */
|
||||
/* newModel->name, newModel->id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
|
||||
/* } else { */
|
||||
/* goto createEnd; */
|
||||
/* } */
|
||||
/* } else { */
|
||||
/* goto createEnd; */
|
||||
/* } */
|
||||
|
||||
/* createEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Creates a model structure\n"); */
|
||||
/* strcat(buf, "Usage: model create name=NAME file=FILENAME\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "load") == 0) { */
|
||||
/* if (!argv[2]) { */
|
||||
/* goto loadEnd; */
|
||||
/* } */
|
||||
|
||||
/* id = (int) strtol(argv[2] + 3, NULL, 10); */
|
||||
|
||||
/* if (id == 0 || (eid = ModelLoad(id)) <= 0) { */
|
||||
/* sprintf(buf + strlen(buf), "Failed to load model id %d\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* sprintf(buf + strlen(buf), "Model id %d loaded with effective " */
|
||||
/* "id %d\n", id, eid); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* loadEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Loads a model structure\n"); */
|
||||
/* strcat(buf, "Usage: model load id=ID\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "unload") == 0) { */
|
||||
/* if (!argv[2]) { */
|
||||
/* goto unloadEnd; */
|
||||
/* } */
|
||||
|
||||
/* id = (int) strtol(argv[2] + 3, NULL, 10); */
|
||||
|
||||
/* if (id == 0 || ModelUnload(id) < 0) { */
|
||||
/* printErr("Failed to unload model id %d\n", id); */
|
||||
/* sprintf(buf + strlen(buf), "Failed to unload model id %d\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* sprintf(buf + strlen(buf), "Model id %d unloaded\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* unloadEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Unloads a model structure\n"); */
|
||||
/* strcat(buf, "Usage: model unload id=ID\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "delete") == 0) { */
|
||||
/* if (!argv[2]) { */
|
||||
/* goto deleteEnd; */
|
||||
/* } */
|
||||
/* // TODO delete model */
|
||||
/* deleteEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Deletes a model structure\n"); */
|
||||
/* strcat(buf, "Usage: model delete id=ID\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "run") == 0) { */
|
||||
/* if (!argv[2]) { */
|
||||
/* goto runEnd; */
|
||||
/* } */
|
||||
|
||||
/* id = (int) strtol(argv[2] + 3, NULL, 10); */
|
||||
|
||||
/* if (id == 0 || (!ModelRun(id))) { */
|
||||
/* sprintf(buf + strlen(buf), "Failed to run model id %d\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* sprintf(buf + strlen(buf), "Model id %d is running\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* runEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Run a model simulation\n"); */
|
||||
/* strcat(buf, "Usage: model run id=ID\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "stop") == 0) { */
|
||||
/* if (!argv[2]) { */
|
||||
/* goto stopEnd; */
|
||||
/* } */
|
||||
|
||||
/* id = (int) strtol(argv[2] + 3, NULL, 10); */
|
||||
|
||||
/* if (id == 0 || (!ModelStop(id))) { */
|
||||
/* sprintf(buf + strlen(buf), "Failed to stop model id %d\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* sprintf(buf + strlen(buf), "Model id %d is running\n", id); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* stopEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Stop a model simulation\n"); */
|
||||
/* strcat(buf, "Usage: model stop id=ID\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "list") == 0) { */
|
||||
/* strcat(buf, "You asked for us to list models\n"); */
|
||||
/* printModels(buf); */
|
||||
/* } */
|
||||
|
||||
/* else if (strcmp(argv[1], "info") == 0) { */
|
||||
/* if (!argv[2]) { */
|
||||
/* goto infoEnd; */
|
||||
/* } */
|
||||
/* // TODO info model */
|
||||
/* infoEnd: */
|
||||
/* // invalid use */
|
||||
/* strcat(buf, "Print info about a model\n"); */
|
||||
/* strcat(buf, "Usage: model info id=ID\n"); */
|
||||
/* goto cmd_ModelEnd; */
|
||||
/* } */
|
||||
|
||||
/* // invalid use */
|
||||
/* else strcat(buf, "{create | delete | load | unload | run | stop | list |" */
|
||||
/* "info}\n"); */
|
||||
|
||||
/* cmd_ModelEnd: */
|
||||
/* return buf; */
|
||||
/* } */
|
||||
|
||||
/* char *cmd_shutdown(char *buf, char **argv, server_t *args) */
|
||||
/* { */
|
||||
/* args->pleaseStop = true; */
|
||||
/* strcat(buf, "Server stopping\n"); */
|
||||
|
||||
/* //XXX ModelShutdown(); */
|
||||
/* strcat(buf, "All model shutted down\n"); */
|
||||
|
||||
/* return buf; */
|
||||
/* } */
|
||||
|
||||
/* char *cmd_help(char *buf, char **argv, server_t *args) */
|
||||
/* { */
|
||||
/* strcat(buf, "List of known commands:\n"); */
|
||||
|
||||
/* return buf; */
|
||||
/* } */
|
147
src/main.c
147
src/main.c
|
@ -1,147 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Main //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/scheduler.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* static server_t *server; */
|
||||
|
||||
/* static void sig_term_handler(int signum) */
|
||||
/* { */
|
||||
/* server->pleaseStop = true; */
|
||||
/* printlog("Server stopping\n"); */
|
||||
|
||||
/* //XXX ModelShutdown(); */
|
||||
/* printlog("All model shutted down\n"); */
|
||||
/* } */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int options;
|
||||
time_t t;
|
||||
int returnValue = SCHED_CONTINUE;
|
||||
struct parameters_t parameters = {0};
|
||||
struct scheduler_t scheduler = {0};
|
||||
|
||||
while ((options = getopt(argc, argv, ":C:M:U:")) != -1) {
|
||||
switch (options) {
|
||||
case 'C':
|
||||
printlog("Config : %s\n", optarg);
|
||||
parameters.configDir = calloc(1, strlen(optarg) + 1);
|
||||
strcpy(parameters.configDir, optarg);
|
||||
break;
|
||||
case 'M':
|
||||
printlog("Models : %s\n", optarg);
|
||||
parameters.modelDir = calloc(1, strlen(optarg) + 1);
|
||||
strcpy(parameters.modelDir, optarg);
|
||||
break;
|
||||
case 'U':
|
||||
printlog("Users : %s\n", optarg);
|
||||
parameters.userDir = calloc(1, strlen(optarg) + 1);
|
||||
strcpy(parameters.userDir, optarg);
|
||||
break;
|
||||
case ':':
|
||||
printerr("Option missing argument : %c\n", optopt);
|
||||
if (parameters.configDir)
|
||||
free(parameters.configDir);
|
||||
|
||||
if (parameters.modelDir)
|
||||
free(parameters.modelDir);
|
||||
|
||||
if (parameters.userDir)
|
||||
free(parameters.userDir);
|
||||
|
||||
return ENOSYS;
|
||||
break;
|
||||
case '?':
|
||||
printerr("Unknown option : %c\n", optopt);
|
||||
if (parameters.configDir)
|
||||
free(parameters.configDir);
|
||||
|
||||
if (parameters.modelDir)
|
||||
free(parameters.modelDir);
|
||||
|
||||
if (parameters.userDir)
|
||||
free(parameters.userDir);
|
||||
|
||||
return ENOSYS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!parameters.configDir | !parameters.modelDir | !parameters.userDir) {
|
||||
printerr("Missing arguments\n");
|
||||
|
||||
if (parameters.configDir)
|
||||
free(parameters.configDir);
|
||||
|
||||
if (parameters.modelDir)
|
||||
free(parameters.modelDir);
|
||||
|
||||
if (parameters.userDir)
|
||||
free(parameters.userDir);
|
||||
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
// Go!
|
||||
printlog("Starting gem-graph-server...\n");
|
||||
|
||||
/* // Register new interrupt handler */
|
||||
/* signal(SIGINT, sig_term_handler); */
|
||||
/* signal(SIGTERM, sig_term_handler); */
|
||||
|
||||
// Initializing random generator
|
||||
t = time(&t);
|
||||
srand ((unsigned)t);
|
||||
|
||||
/* server = calloc(1, sizeof(*server)); */
|
||||
|
||||
// Initializing model system
|
||||
model_system_init (¶meters);
|
||||
|
||||
/* // Launching server */
|
||||
/* server_init(server); */
|
||||
|
||||
/* // Waiting for termination */
|
||||
/* server_wait(server); */
|
||||
|
||||
/* // Exiting */
|
||||
/* returnValue |= server->returnValue; */
|
||||
/* ModelSystemDestroy(); */
|
||||
/* free(server); */
|
||||
/* server = NULL; */
|
||||
|
||||
while (returnValue > SCHED_NON_FATAL_ERRORS) {
|
||||
returnValue = sched_start (&scheduler, ¶meters);
|
||||
}
|
||||
|
||||
model_system_shutdown();
|
||||
|
||||
free(parameters.userDir);
|
||||
free(parameters.modelDir);
|
||||
free(parameters.configDir);
|
||||
|
||||
return returnValue;
|
||||
}
|
620
src/model.c
620
src/model.c
|
@ -1,620 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Model management module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021-2024 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/model.h"
|
||||
#include "../include/arrows.h"
|
||||
|
||||
#define ALLOWED_RADIUS 10
|
||||
#define READ_SITE 1 << 0
|
||||
#define READ_WEIGHT 1 << 1
|
||||
#define READ_X 1 << 2
|
||||
#define READ_Y 1 << 3
|
||||
#define READ_Z 1 << 4
|
||||
#define SUCCESSFUL_READ_ARROW_X (READ_SITE | READ_WEIGHT | READ_X)
|
||||
#define SUCCESSFUL_READ_ARROW_XY (READ_SITE | READ_WEIGHT | READ_X | READ_Y)
|
||||
#define SUCCESSFUL_READ_ARROW_XYZ (READ_SITE | READ_WEIGHT | READ_X | READ_Y | READ_Z)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct model_t *knownModels = NULL;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Recursively populates a hash table with XML nodes, using the node paths as keys.
|
||||
*
|
||||
* @param self The self structure containing hash table containing
|
||||
* nodes indexed by their paths to populate
|
||||
* @param node The current node being processed.
|
||||
* @param currentPath The path to the current node.
|
||||
*/
|
||||
void model_populate_hashtable (struct model_t *self, xmlNode *node, char *currentPath)
|
||||
{
|
||||
if (node == NULL) return;
|
||||
|
||||
assert(self->hashtable == NULL);
|
||||
|
||||
// Skip text nodes and others that are not element nodes
|
||||
if (node->type != XML_ELEMENT_NODE) {
|
||||
model_populate_hashtable (node->next, self->hashtable, currentPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate new path
|
||||
char newPath[1024]; // large enough
|
||||
if (currentPath && strlen(currentPath) > 0) {
|
||||
snprintf (newPath, sizeof(newPath), "%s/%s", currentPath, node->name);
|
||||
} else {
|
||||
snprintf (newPath, sizeof(newPath), "%s", node->name); // Root element
|
||||
}
|
||||
|
||||
// Add current node to hash table with its path as the key
|
||||
xmlHashAddEntry (self->hashtable, (const xmlChar *)newPath, node);
|
||||
|
||||
// Recurse into child nodes with the updated path
|
||||
model_populate_hashtable (self, node->children, newPath);
|
||||
|
||||
// Continue with the next sibling
|
||||
model_populate_hashtable (self, node->next, currentPath);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds a node by a path of tags.
|
||||
*
|
||||
* @param self The self structure containing hash table containing
|
||||
* nodes indexed by their paths.
|
||||
* @param path The path to the tag, with '/' as the delimiter.
|
||||
* @return The content of the tag at the end of the path, or NULL if not found.
|
||||
*/
|
||||
xmlNodePtr model_get_node (struct model_t *self, const char *path)
|
||||
{
|
||||
assert(self->hashtable != NULL);
|
||||
|
||||
return (xmlNodePtr)xmlHashLookup (self->hashtable, (const xmlChar *)path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the content of an XML node identified by its path in the hash table.
|
||||
*
|
||||
* @param self The self structure containing hash table containing
|
||||
* nodes indexed by their paths.
|
||||
* @param path The path to the node to modify.
|
||||
* @param newContent The new content to set for the node.
|
||||
* @return 1 if the node was found and modified, 0 otherwise.
|
||||
*/
|
||||
int model_modify_node (struct model_t *self,
|
||||
const char *path,
|
||||
const char *newContent)
|
||||
{
|
||||
assert(self->hashtable != NULL);
|
||||
|
||||
xmlNodePtr node = model_get_node (self, path);
|
||||
if (node) {
|
||||
// Free the current content of the node, if any
|
||||
xmlNodeSetContent (node, (const xmlChar *)""); // Clear existing content
|
||||
// Set new content
|
||||
xmlNodeSetContent (node, (const xmlChar *)newContent);
|
||||
return 1; // Success
|
||||
}
|
||||
return 0; // Node not found or unable to modify
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the value of an attribute for a node identified by its path.
|
||||
*
|
||||
* @param self The self structure containing hash table containing
|
||||
* nodes indexed by their paths.
|
||||
* @param nodePath The path to the node.
|
||||
* @param attributeName The name of the attribute.
|
||||
* @return The value of the attribute, or NULL if not found.
|
||||
*/
|
||||
char *model_get_attribute (struct model_t *self,
|
||||
const char* nodePath,
|
||||
const char* attributeName)
|
||||
{
|
||||
assert(self->hashtable != NULL);
|
||||
|
||||
xmlNodePtr node = (xmlNodePtr)xmlHashLookup (self->hashtable, (const xmlChar*)nodePath);
|
||||
if (node) {
|
||||
return getAttributeValue (node, attributeName);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or updates the value of an attribute for a node identified by its path.
|
||||
*
|
||||
* @param self The self structure containing hash table containing
|
||||
* nodes indexed by their paths.
|
||||
* @param nodePath The path to the node.
|
||||
* @param attributeName The name of the attribute to set.
|
||||
* @param attributeValue The value to set for the attribute.
|
||||
* @return 1 on success, 0 on failure.
|
||||
*/
|
||||
int model_set_attribute (struct model_t *self,
|
||||
const char* nodePath,
|
||||
const char* attributeName,
|
||||
const char* attributeValue)
|
||||
{
|
||||
assert(self->hashtable != NULL);
|
||||
|
||||
xmlNodePtr node = (xmlNodePtr)xmlHashLookup (self->hashtable, (const xmlChar*)nodePath);
|
||||
if (node) {
|
||||
return setAttributeValue (node, attributeName, attributeValue);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a node recursively to a new sibling node with a modified attribute and updates the self->hashtable.
|
||||
*
|
||||
* @param node The node to copy.
|
||||
* @param self The self structure for tracking nodes by path.
|
||||
* @param originalNodePath The path of the original node in the self->hashtable.
|
||||
* @param attributeName The name of the attribute to modify in the copied node.
|
||||
* @param newAttributeValue The new value for the specified attribute in the copied node.
|
||||
* @return The copied node with the modified attribute, or NULL on failure.
|
||||
*/
|
||||
xmlNodePtr model_copy_node(struct model_t *self,
|
||||
xmlNodePtr node,
|
||||
const char* originalNodePath,
|
||||
const char* attributeName,
|
||||
const char* newAttributeValue)
|
||||
{
|
||||
assert(self->hashtable != NULL);
|
||||
|
||||
// Deep copy the node
|
||||
xmlNodePtr copiedNode = xmlDocCopyNode(node, self->doc, 1);
|
||||
if (copiedNode == NULL) {
|
||||
return NULL; // Failed to copy
|
||||
}
|
||||
|
||||
// Modify the specified attribute in the copied node
|
||||
xmlSetProp (copiedNode, (const xmlChar*)attributeName, (const xmlChar*)newAttributeValue);
|
||||
|
||||
// Insert the copied node as the next sibling of the original node
|
||||
xmlAddNextSibling (node, copiedNode);
|
||||
|
||||
// Calculate the new node's path.
|
||||
char newPath[1024];
|
||||
snprintf (newPath, sizeof(newPath), "%s_copy", originalNodePath);
|
||||
|
||||
// Update the self->hashtable with the new node's path
|
||||
xmlHashAddEntry (self->hashtable, (const xmlChar*)newPath, copiedNode);
|
||||
|
||||
return copiedNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over all sibling nodes of a given node, typically used to process
|
||||
* each child of a specific parent node.
|
||||
*
|
||||
* This function takes a starting node (expected to be a parent node like <states>)
|
||||
* and iterates through all of its child nodes.
|
||||
* It calls a user-provided callback function for each child node that is an
|
||||
* element node (ignores text and other types of nodes).
|
||||
*
|
||||
* @param node The starting node whose siblings (children) will be iterated
|
||||
* over. This node is not processed by the callback, only its siblings are.
|
||||
* @param processNode A callback function that will be called for each sibling
|
||||
* node. This function should have a signature of
|
||||
* void functionName(xmlNodePtr node, void* userData), where
|
||||
* 'node' is the current sibling element node, and
|
||||
* 'userData' is a pointer to user-defined data passed
|
||||
* through iterateSiblings.
|
||||
* @param userData A void pointer to user-defined data. This can be used to pass
|
||||
* additional information to the callback function. It is passed
|
||||
* directly through to the callback function as its second argument.
|
||||
*/
|
||||
void model_iterate_node(struct model_t *self,
|
||||
xmlNodePtr node,
|
||||
void (*processNode)(xmlNodePtr node, void* userData), void* userData)
|
||||
{
|
||||
for (xmlNodePtr curNode = node->children; curNode; curNode = curNode->next) {
|
||||
if (curNode->type == XML_ELEMENT_NODE) {
|
||||
processNode (curNode, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
char model_get_dim (struct model_t *self)
|
||||
{
|
||||
xmlAttr *attribute;
|
||||
xmlChar* value;
|
||||
xmlNodePtr node = model_get_node(self,
|
||||
(xmlChar *)"parameters/space-param/dimension");
|
||||
|
||||
if (xmlHasProp (node, (xmlChar *) "z")) return 3;
|
||||
if (xmlHasProp (node, (xmlChar *) "y")) return 2;
|
||||
if (xmlHasProp (node, (xmlChar *) "x")) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long model_get_dim_value (struct model_t *self, const char *axis)
|
||||
{
|
||||
xmlAttr *attribute;
|
||||
xmlChar *value;
|
||||
long ret_value;
|
||||
xmlNodePtr node = model_get_node(self,
|
||||
(xmlChar *)"parameters/space-param/dimension");
|
||||
|
||||
return model_get_node_long_attrib(node, axis);
|
||||
}
|
||||
|
||||
char model_get_multiplicity (struct model_t *self)
|
||||
{
|
||||
xmlAttr *attribute;
|
||||
xmlChar* value;
|
||||
xmlNodePtr node = model_get_node(self,
|
||||
(xmlChar *)"parameters/space-param/site_multiplicity");
|
||||
|
||||
if (node->children)
|
||||
if (node->children->content)
|
||||
return (char)strtol((char *)node->children->content, NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static bool model_init(struct model_t *self)
|
||||
{
|
||||
xmlNode *node;
|
||||
|
||||
/*
|
||||
* this initialize the library and check potential ABI mismatches
|
||||
* between the version it was compiled for and the actual shared
|
||||
* library used.
|
||||
*/
|
||||
LIBXML_TEST_VERSION
|
||||
|
||||
self->doc = xmlReadFile(self->filename, NULL, 0);
|
||||
|
||||
if (self->doc == NULL ) {
|
||||
printerr("Error trying to open the XML model !\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
node = xmlDocGetRootElement(self->doc);
|
||||
|
||||
if (node == NULL) {
|
||||
printerr("Empty XML model !\n");
|
||||
xmlFreeDoc(self->doc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xmlStrcmp(node->name, (xmlChar *) "gem-graph-model")) {
|
||||
printerr("document of the wrong type, root node != gem-graph-model\n");
|
||||
xmlFreeDoc(self->doc);
|
||||
return false;
|
||||
}
|
||||
|
||||
model_populate_hashtable(self, node, "");
|
||||
|
||||
if (self->hashtable == NULL) {
|
||||
printerr("Can't create model hash table !\n");
|
||||
xmlFreeDoc(self->doc);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool model_shutdown(struct model_t *self)
|
||||
{
|
||||
xmlFreeDoc(self->doc);
|
||||
xmlHashFree(self->hashtable, NULL);
|
||||
// This is to debug memory for regression tests
|
||||
//xmlMemoryDump();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool model_load (struct model_t *self)
|
||||
{
|
||||
char state_id[30] = {0};
|
||||
char conditions_id[30] = {0};
|
||||
struct arrow_t *arrow;
|
||||
struct arrow_t *arrow_next;
|
||||
struct arrow_t *arrow_prev;
|
||||
int n_conditions;
|
||||
|
||||
|
||||
if (!model_init (self))
|
||||
return false;
|
||||
|
||||
printlog ("Loading %s...\n", self->filename);
|
||||
|
||||
// Dimension
|
||||
self->dimension = model_get_dim (self);
|
||||
printlog ("Dimension : %d\n", self->dimension);
|
||||
|
||||
// Dimensions
|
||||
self->space = calloc (1, sizeof(struct space_t));
|
||||
self->space->x_dim = 0;
|
||||
self->space->y_dim = 0;
|
||||
self->space->z_dim = 0;
|
||||
|
||||
switch(self->dimension) {
|
||||
case 3:
|
||||
self->space->z_dim = model_get_dim_value (self, "z");
|
||||
case 2:
|
||||
self->space->y_dim = model_get_dim_value (self, "y");
|
||||
case 1:
|
||||
self->space->x_dim = model_get_dim_value (self, "x");
|
||||
|
||||
printlog("x_dim=%d, y_dim=%d, z_dim=%d\n",
|
||||
self->space->x_dim,
|
||||
self->space->y_dim,
|
||||
self->space->z_dim);
|
||||
break;
|
||||
default:
|
||||
printerr ("Invalid dimension value : %d\n", self->dimension);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Space allocation
|
||||
self->space->units = calloc (self->space->x_dim
|
||||
* self->space->y_dim
|
||||
* self->space->z_dim,
|
||||
sizeof(struct space_unit_t)
|
||||
+ self->multiplicity * sizeof(struct arrow_t*));
|
||||
|
||||
// Multiplicity
|
||||
self->multiplicity = model_get_multiplicity(self);
|
||||
printlog("Multiplicity : %d\n", self->multiplicity);
|
||||
|
||||
// States and initial state
|
||||
if (!model_get_next_state(self, &state_id)) {
|
||||
printerr("No valid state to load\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
self->states = calloc (1, sizeof(struct state_t));
|
||||
self->n_states = 1;
|
||||
memcpy(&self->states[0].id, &state_id, 25);
|
||||
self->states[0].space = self->space;
|
||||
|
||||
printlog("Initial state : %s\n", &self->states[0].id);
|
||||
|
||||
// Initial state arrows
|
||||
while (arrow = arrow_new (self->arrows),
|
||||
model_get_next_arrow(self,
|
||||
arrow,
|
||||
&self->states[0].id,
|
||||
self->dimension)) {
|
||||
if (arrow->x > self->space->x_dim ||
|
||||
arrow->y > self->space->y_dim ||
|
||||
arrow->z > self->space->z_dim) {
|
||||
printerr("Invalid coordinates for arrow %d (%d,%d,%d)\n",
|
||||
self->n_arrows,
|
||||
arrow->x,
|
||||
arrow->y,
|
||||
arrow->z);
|
||||
return false;
|
||||
}
|
||||
|
||||
printlog("Loading arrow %d (%d,%d,%d, %d)\n",
|
||||
self->n_arrows,
|
||||
arrow->x,
|
||||
arrow->y,
|
||||
arrow->z,
|
||||
arrow->site);
|
||||
|
||||
self->space->units [
|
||||
arrow->x
|
||||
+ self->space->x_dim * arrow->y
|
||||
+ self->space->x_dim * self->space->y_dim * arrow->z
|
||||
].sites[arrow->site] = arrow;
|
||||
|
||||
if (self->n_arrows == 0) {
|
||||
self->arrows = arrow;
|
||||
}
|
||||
|
||||
self->n_arrows++;
|
||||
}
|
||||
|
||||
printlog("Loaded %d arrows\n", self->n_arrows);
|
||||
|
||||
self->states[0].arrows = self->arrows;
|
||||
|
||||
// Conditions
|
||||
if (!model_get_next_conditions(self, &conditions_id)) {
|
||||
printerr("No valid conditions to load\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loading each condition
|
||||
self->conditions = condition_new (self->conditions);
|
||||
|
||||
if (model_get_next_condition(self,
|
||||
self->conditions,
|
||||
&conditions_id,
|
||||
self->dimension)) {
|
||||
n_conditions = 1;
|
||||
while (model_get_next_arrow(self,
|
||||
condition_new (self->conditions),
|
||||
&conditions_id,
|
||||
self->dimension)) {
|
||||
n_conditions++;
|
||||
}
|
||||
}
|
||||
|
||||
printlog("Loaded %d conditions\n", n_conditions);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool model_unload (struct model_t *self)
|
||||
{
|
||||
if (!model_shutdown (self))
|
||||
return false;
|
||||
|
||||
if (self->owner_name) {
|
||||
free(self->owner_name);
|
||||
self->owner_name = NULL;
|
||||
}
|
||||
if (self->model_name) {
|
||||
free(self->model_name);
|
||||
self->model_name = NULL;
|
||||
}
|
||||
if (self->space) {
|
||||
if (self->space->units) {
|
||||
free(self->space->units);
|
||||
self->space->units = NULL;
|
||||
}
|
||||
free(self->space);
|
||||
self->space = NULL;
|
||||
}
|
||||
if (self->arrows) {
|
||||
while (self->arrows) {
|
||||
self->arrows = arrow_destroy (self->arrows);
|
||||
}
|
||||
}
|
||||
if (self->states) {
|
||||
free(self->states);
|
||||
self->states = NULL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct model_t *model_new(const char *path, const char *basename)
|
||||
{
|
||||
struct model_t *self = NULL;
|
||||
struct model_t *prev = NULL;
|
||||
|
||||
// Allocate and insert in the list
|
||||
self = calloc (1, sizeof(struct model_t));
|
||||
|
||||
// We want a cyclic chain
|
||||
// This is the first model
|
||||
if (!knownModels) {
|
||||
knownModels = self;
|
||||
self->next = self;
|
||||
self->prev = self;
|
||||
|
||||
// This is not the first model
|
||||
} else {
|
||||
self->next = knownModels->next;
|
||||
knownModels->next = self;
|
||||
self->prev = knownModels;
|
||||
}
|
||||
|
||||
// Allocate filename with trailing '\0'
|
||||
self->filename =
|
||||
calloc (1, strlen (path)
|
||||
+ sizeof((char)'/')
|
||||
+ strlen (basename)
|
||||
+ sizeof((char)'\0'));
|
||||
|
||||
memcpy (self->filename,
|
||||
path,
|
||||
strlen (path));
|
||||
|
||||
self->filename[
|
||||
strlen (path)] = '/';
|
||||
|
||||
memcpy (self->filename
|
||||
+ strlen (path)
|
||||
+ sizeof((char)'/'),
|
||||
basename,
|
||||
strlen (basename));
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void model_destroy(struct model_t *self)
|
||||
{
|
||||
if (self->filename) {
|
||||
free(self->filename);
|
||||
self->filename = NULL;
|
||||
}
|
||||
|
||||
if (self->next != self) {
|
||||
self->prev->next = self->next;
|
||||
self->next->prev = self->prev;
|
||||
}
|
||||
|
||||
free(self);
|
||||
}
|
||||
|
||||
void model_system_init (struct parameters_t *parameters)
|
||||
{
|
||||
struct dirent *modelDirEntry = NULL;
|
||||
struct model_t *new_model;
|
||||
DIR *modelDir = NULL;
|
||||
char *extensionPosition;
|
||||
int i;
|
||||
|
||||
// Open model directory
|
||||
if ((modelDir = opendir (parameters->modelDir)) <= 0) {
|
||||
printerr ("Could not open %s\n", parameters->modelDir);
|
||||
}
|
||||
|
||||
while ((modelDirEntry = readdir (modelDir)) != NULL) {
|
||||
if ((extensionPosition = strstr (modelDirEntry->d_name, ".xml"))) {
|
||||
|
||||
new_model = model_new (parameters->modelDir, modelDirEntry->d_name);
|
||||
|
||||
// Ask to parse the new model
|
||||
if (model_load (new_model)) {
|
||||
// XXX Check model is valid and/or parsed
|
||||
printlog ("Loaded %s\n", new_model->filename);
|
||||
} else {
|
||||
printerr ("Failed to load %s\n", new_model->filename);
|
||||
model_unload (new_model);
|
||||
model_destroy (new_model);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(modelDir);
|
||||
}
|
||||
|
||||
void model_system_shutdown (void)
|
||||
{
|
||||
struct model_t *model = knownModels;
|
||||
struct model_t *next = NULL;
|
||||
|
||||
while ((model != model->next)) {
|
||||
printlog ("Freeing %s\n", model->filename);
|
||||
next = model->next;
|
||||
model_unload(model);
|
||||
model_destroy(model);
|
||||
model = next;
|
||||
}
|
||||
|
||||
if (model) {
|
||||
model_unload (model);
|
||||
model_destroy (model);
|
||||
}
|
||||
|
||||
// Cleanup function for the XML library
|
||||
xmlCleanupParser();
|
||||
}
|
133
src/scheduler.c
133
src/scheduler.c
|
@ -1,133 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Scheduler module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/scheduler.h"
|
||||
#include "../include/worker.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
static int sched_new_id (void)
|
||||
{
|
||||
static int id = 0;
|
||||
return id;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
static int sched_run(struct scheduler_t *self,
|
||||
struct parameters_t *parameters,
|
||||
struct model_t *model)
|
||||
{
|
||||
int n_threads = omp_get_max_threads();
|
||||
int n_arrows;
|
||||
int workers_per_cycle;
|
||||
int max_cycles;
|
||||
int max_workers;
|
||||
|
||||
self->pleaseStop = false;
|
||||
self->n_workers = 0;
|
||||
n_arrows = 2000;
|
||||
max_cycles = 1;
|
||||
workers_per_cycle = (int) round((double)n_arrows / (double)n_threads);
|
||||
max_workers = workers_per_cycle * n_threads * max_cycles;
|
||||
|
||||
printlog("Begin simulation of model %d with %d workers per cycle"
|
||||
" (%d arrows to work on)\n",
|
||||
model->id,
|
||||
workers_per_cycle,
|
||||
n_arrows);
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
int thread_num;
|
||||
thread_num = omp_get_thread_num();
|
||||
|
||||
while (!self->pleaseStop) {
|
||||
// Get an ID;
|
||||
self->workers[thread_num]->id = self->n_workers;
|
||||
|
||||
// Elect an arrow (XXX TODO)
|
||||
self->workers[thread_num]->elected_arrow = NULL;
|
||||
|
||||
// Launch evaluation
|
||||
worker_start(self->workers[thread_num], self);
|
||||
|
||||
// Check if this is the end
|
||||
if (self->n_workers > max_workers) {
|
||||
self->pleaseStop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printlog("End of simulation (%d workers executed)\n",
|
||||
self->n_workers);
|
||||
|
||||
return SCHED_NORMAL_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
int sched_start (struct scheduler_t *self, struct parameters_t *parameters)
|
||||
{
|
||||
int n_threads = omp_get_max_threads();
|
||||
int returnValue;
|
||||
struct model_t *model;
|
||||
self->id = sched_new_id();
|
||||
|
||||
printlog("Scheduler %d initialized with %d threads\n",
|
||||
self->id,
|
||||
n_threads);
|
||||
|
||||
|
||||
// Allocating workers
|
||||
self->workers = calloc(n_threads, sizeof(struct worker_t*));
|
||||
for (int i = 0; i < n_threads; i++) {
|
||||
self->workers[i] = calloc(1, sizeof(struct worker_t));
|
||||
}
|
||||
|
||||
// Retrieve models
|
||||
model = self->models;
|
||||
while(model) {
|
||||
printlog ("Scheduling model %d\n", model->id);
|
||||
returnValue = sched_run(self, parameters, self->models);
|
||||
model = model->next;
|
||||
}
|
||||
|
||||
// Freeing workers
|
||||
for (int i = 0; i < n_threads; i++) {
|
||||
free(self->workers[i]);
|
||||
}
|
||||
free(self->workers);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
248
src/server.c
248
src/server.c
|
@ -1,248 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server management module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/server.h"
|
||||
#include "../include/cmds.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* static void *server_main(void *server); */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* #define SEND_BUFFER_SIZE 80 * 24 */
|
||||
/* #define RECEIVE_BUFFER_SIZE 80 */
|
||||
/* void *server_communication_instance(void *serverCom) */
|
||||
/* { */
|
||||
/* servercom_t *args; */
|
||||
/* char **argv = NULL; */
|
||||
/* char receiveBuff[RECEIVE_BUFFER_SIZE]; */
|
||||
/* char sendBuff[SEND_BUFFER_SIZE]; */
|
||||
/* int tokenIndex, bytesReceived, clientPort; */
|
||||
/* char clientIP[16]; */
|
||||
|
||||
/* args = (servercom_t*) serverCom; */
|
||||
|
||||
/* // Get ip address from client */
|
||||
/* inet_ntop(AF_INET, */
|
||||
/* &args->clientAddr.sin_addr, */
|
||||
/* clientIP, */
|
||||
/* args->sockLen); */
|
||||
|
||||
/* // Get port number from client */
|
||||
/* clientPort = ntohs(args->clientAddr.sin_port); */
|
||||
|
||||
/* //Accept and incoming connection */
|
||||
/* while(!args->pleaseStop) { */
|
||||
|
||||
/* // Zeroing buffer */
|
||||
/* bzero(receiveBuff, RECEIVE_BUFFER_SIZE); */
|
||||
/* //printLog("Waiting for commands...\n"); */
|
||||
|
||||
/* // Read the message from client and copy it in buffer */
|
||||
/* bytesReceived = recv(args->sockfd, receiveBuff, RECEIVE_BUFFER_SIZE, 0); */
|
||||
/* if (bytesReceived == -1) { */
|
||||
/* printErr("Could not receive data! (%s)\n", strerror(errno)); */
|
||||
/* break; */
|
||||
/* }; */
|
||||
|
||||
/* // Ignore null-sized request */
|
||||
/* if (bytesReceived == 0) */
|
||||
/* break; */
|
||||
|
||||
/* // Print buffer which contains the client request */
|
||||
/* printLog("Client %s:%d request : '%s'\n", */
|
||||
/* clientIP, */
|
||||
/* clientPort, */
|
||||
/* receiveBuff); */
|
||||
|
||||
/* if (receiveBuff[0] == '\0') //XXX */
|
||||
/* break; */
|
||||
|
||||
/* // get args in an array */
|
||||
/* tokenIndex = 0; */
|
||||
/* argv = (char**) realloc(argv, 1 * sizeof(char*)); */
|
||||
/* argv[0] = strtok(receiveBuff, " "); */
|
||||
/* while (argv[tokenIndex]) { */
|
||||
/* tokenIndex++; */
|
||||
/* argv = (char**) realloc(argv, (tokenIndex+1) * sizeof(char*)); */
|
||||
/* argv[tokenIndex] = strtok(NULL, " "); */
|
||||
/* } */
|
||||
|
||||
/* // Zeroing buffer */
|
||||
/* bzero(sendBuff, RECEIVE_BUFFER_SIZE); */
|
||||
|
||||
/* // Execute command by first arg in cmdList */
|
||||
/* for (int i = 0; i < LEN(cmdList); i++) { */
|
||||
/* if (strcmp(cmdList[i].name, argv[0]) == 0) { */
|
||||
/* cmdList[i].execute(sendBuff, argv, args->associatedServer); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* // and send that buffer to client */
|
||||
/* send(args->sockfd, sendBuff, SEND_BUFFER_SIZE, 0); */
|
||||
/* } */
|
||||
|
||||
/* close(args->sockfd); */
|
||||
/* if (argv) { */
|
||||
/* free(argv); */
|
||||
/* argv = NULL; */
|
||||
/* } */
|
||||
/* printLog("Disconnected from %s:%d\n", clientIP, clientPort); */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
|
||||
/* // -------------------------------------------------------------------------- // */
|
||||
/* // Server main function // */
|
||||
/* // -------------------------------------------------------------------------- // */
|
||||
/* #define PORT 9000 */
|
||||
/* #define MAX_CONNECTION 100 */
|
||||
|
||||
/* static void *server_main(void *server) */
|
||||
/* { */
|
||||
/* Server_t *args; */
|
||||
/* ServerCommunication_t serverSlots[MAX_CONNECTION] = {0}; */
|
||||
/* int connfd, flags, threadStatus, serverSlotIndex = 0; */
|
||||
/* uint socklen; */
|
||||
/* struct sockaddr_in servaddr; */
|
||||
/* char clientIP[16]; */
|
||||
|
||||
/* // Get args */
|
||||
/* args = (Server_t*) server; */
|
||||
/* args->returnValue = 0; */
|
||||
/* printLog("Server #%lu online\n", args->id); */
|
||||
|
||||
/* // Create socket */
|
||||
/* args->sockfd = socket(AF_INET, SOCK_STREAM, 0); */
|
||||
/* if (args->sockfd == -1) { */
|
||||
/* printErr("Socket creation failed! (%s)\n", strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* // Get socket flags */
|
||||
/* flags = fcntl(args->sockfd, F_GETFL); */
|
||||
/* if (flags == -1) { */
|
||||
/* printErr("Socket parameters getting failed! (%s)\n", strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* // Change socket flags to non-blocking */
|
||||
/* if (fcntl(args->sockfd, F_SETFL, flags | O_NONBLOCK) < 0) { */
|
||||
/* printErr("Socket non-blocking setting failed! (%s)\n", strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* // Prepare binding structure */
|
||||
/* bzero(&servaddr, sizeof(servaddr)); */
|
||||
|
||||
/* // Assign IP and PORT */
|
||||
/* servaddr.sin_family = AF_INET; */
|
||||
/* servaddr.sin_addr.s_addr = htonl(INADDR_ANY); */
|
||||
/* servaddr.sin_port = htons(PORT); */
|
||||
|
||||
/* // Binding newly created socket */
|
||||
/* if ((bind(args->sockfd, (struct sockaddr*)&servaddr, */
|
||||
/* sizeof(servaddr))) == -1) { */
|
||||
/* printErr("Socket bind failed! (%s)\n", strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* // Now server is ready to listen and verification */
|
||||
/* if (listen(args->sockfd, MAX_CONNECTION) == -1) { */
|
||||
/* printErr("Socket listening failed! (%s)\n", strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* socklen = sizeof(struct sockaddr_in); */
|
||||
|
||||
/* // Get server socket address structure */
|
||||
/* if (getsockname(args->sockfd, (struct sockaddr *)&servaddr, &socklen) */
|
||||
/* == -1) { */
|
||||
/* printErr("Could not get socket structure! (%s)\n", strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* printLog("Server listening...\n"); */
|
||||
|
||||
/* while (!args->pleaseStop) { */
|
||||
|
||||
/* // Accept the data packet from client */
|
||||
/* connfd = accept(args->sockfd, */
|
||||
/* (struct sockaddr*) &serverSlots[serverSlotIndex].clientAddr, */
|
||||
/* &socklen); */
|
||||
/* if (connfd < 0) { */
|
||||
/* // If error is not due to lack of clients connecting, this is error */
|
||||
/* if (errno != EWOULDBLOCK && errno != EAGAIN) { */
|
||||
/* printErr("Server acccept failed! (%s)\n", strerror(errno)); */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
/* sleep(1); */
|
||||
/* } else { */
|
||||
/* // Client connected */
|
||||
/* // get IP addr from client */
|
||||
/* inet_ntop(AF_INET, */
|
||||
/* &(serverSlots[serverSlotIndex].clientAddr.sin_addr), */
|
||||
/* clientIP, socklen); */
|
||||
/* printLog("Client accepted from %s:%d\n", */
|
||||
/* clientIP, */
|
||||
/* ntohs(serverSlots[serverSlotIndex].clientAddr.sin_port)); // TODO envisager déplacement dans thread */
|
||||
|
||||
/* // Populate communicator slot */
|
||||
/* serverSlots[serverSlotIndex].sockLen = socklen; // XXX */
|
||||
/* serverSlots[serverSlotIndex].sockfd = connfd; */
|
||||
/* serverSlots[serverSlotIndex].associatedServer = args; */
|
||||
|
||||
/* // Create thread */
|
||||
/* threadStatus = pthread_create(&serverSlots[serverSlotIndex].id, */
|
||||
/* NULL, */
|
||||
/* server_communication_instance, */
|
||||
/* (void*)&serverSlots[serverSlotIndex]); */
|
||||
/* if(threadStatus != 0) { */
|
||||
/* printErr("Error from pthread: %d (%s)\n", */
|
||||
/* threadStatus, strerror(errno)); */
|
||||
/* args->returnValue = 1; */
|
||||
/* goto serverExiting; */
|
||||
/* } */
|
||||
|
||||
/* serverSlotIndex++; */
|
||||
/* //printLog("Accepted connection. Server will now listen...\n"); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* serverExiting: */
|
||||
/* for (int i; i < serverSlotIndex; i++) { */
|
||||
/* serverSlots[i].pleaseStop = true; */
|
||||
/* usleep(10000); */
|
||||
/* pthread_cancel(serverSlots[i].id); */
|
||||
/* pthread_join(serverSlots[i].id, NULL); */
|
||||
/* } */
|
||||
/* close(args->sockfd); */
|
||||
/* printLog("Server #%lu offline\n", args->id); */
|
||||
/* return NULL; */
|
||||
/* } */
|
|
@ -1,28 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Supervisor module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/supervisor.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Arrows tests //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../centers.c"
|
|
@ -1,177 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Centers tests //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../centers.c"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// Tests for Center_t functions
|
||||
//
|
||||
|
||||
void printCenters(Center_t *firstCenter)
|
||||
{
|
||||
while (firstCenter) {
|
||||
printf("Center %p\n\tNext %p\n\tPrev %p\n\n",
|
||||
firstCenter,
|
||||
firstCenter->next,
|
||||
firstCenter->prev
|
||||
);
|
||||
firstCenter = firstCenter->next;
|
||||
}
|
||||
}
|
||||
|
||||
bool TestCenterRemove
|
||||
(void)
|
||||
{
|
||||
Center_t *anyCenter = NULL;
|
||||
|
||||
// adding a something to a bad pointer
|
||||
CenterRemove(anyCenter);
|
||||
|
||||
//printf("* Status of centers list after deleting NULL\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter == NULL);
|
||||
|
||||
anyCenter = calloc(1, sizeof(*anyCenter));
|
||||
|
||||
//printf("* Initial status of centers list\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter->next == NULL);
|
||||
assert(anyCenter->prev == NULL);
|
||||
assert(anyCenter != NULL);
|
||||
|
||||
// Deleting a lonely pointer
|
||||
CenterRemove(anyCenter);
|
||||
|
||||
//printf("* Status of centers list after deleting a lonely center\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
|
||||
anyCenter = calloc(1, sizeof(*anyCenter));
|
||||
|
||||
Center_t *oldfirst = anyCenter->next;
|
||||
Center_t *oldsecond = anyCenter->next->next;
|
||||
|
||||
|
||||
// Deleting a the first pointer
|
||||
CenterRemove(anyCenter->next);
|
||||
|
||||
//printf("* Status of centers list after deleting the head center\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter->next == oldsecond);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestCenterAdd(void)
|
||||
{
|
||||
Center_t *anyCenter = NULL;
|
||||
|
||||
// adding a something to a bad pointer
|
||||
CenterAdd(anyCenter, NULL);
|
||||
|
||||
//printf("* Status of centers list after adding something to NULL\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter == NULL);
|
||||
|
||||
anyCenter = calloc(1, sizeof(Center_t));
|
||||
|
||||
//printf("* Initial status of centers list\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter->next == NULL);
|
||||
assert(anyCenter->prev == NULL);
|
||||
assert(anyCenter != NULL);
|
||||
|
||||
// adding a bad pointer
|
||||
CenterAdd(anyCenter, NULL);
|
||||
|
||||
//printf("* Status of centers list after adding NULL\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter->next == NULL);
|
||||
assert(anyCenter->prev == NULL);
|
||||
assert(anyCenter != NULL);
|
||||
|
||||
// adding a good pointer
|
||||
Center_t *goodpointer = calloc(1, sizeof(Center_t));
|
||||
CenterAdd(anyCenter, goodpointer);
|
||||
|
||||
//printf("* Status of centers list after adding a center\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter != NULL);
|
||||
assert(anyCenter->next == goodpointer);
|
||||
assert(anyCenter->prev == NULL);
|
||||
assert(goodpointer->prev == anyCenter);
|
||||
assert(goodpointer->next == NULL);
|
||||
|
||||
// adding another good pointer
|
||||
Center_t *newgoodpointer = calloc(1, sizeof(Center_t));
|
||||
CenterAdd(anyCenter, newgoodpointer);
|
||||
|
||||
//printf("* Status of centers list after adding another center\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter != NULL);
|
||||
assert(anyCenter->next == newgoodpointer);
|
||||
assert(anyCenter->prev == NULL);
|
||||
assert(newgoodpointer->prev == anyCenter);
|
||||
assert(newgoodpointer->next == goodpointer);
|
||||
|
||||
// adding another good pointer
|
||||
Center_t *strangepointer = calloc(1, sizeof(Center_t));
|
||||
strangepointer->next = (Center_t*)0xCAFEBABE;
|
||||
strangepointer->prev = (Center_t*)0xCAFEBABE;
|
||||
CenterAdd(anyCenter, strangepointer);
|
||||
|
||||
//printf("* Status of centers list after adding a strange center\n");
|
||||
//printCenters(anyCenter);
|
||||
|
||||
assert(anyCenter != NULL);
|
||||
assert(anyCenter->next == strangepointer);
|
||||
assert(anyCenter->prev == NULL);
|
||||
assert(strangepointer->prev != (Center_t*)0xCAFEBABE);
|
||||
assert(strangepointer->next != (Center_t*)0xCAFEBABE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("\n==== Testing centers.c/CenterAdd() ====\n");
|
||||
TestCenterAdd();
|
||||
printf("\n==== Testing centers.c/CenterAdd() ==== : OK\n");
|
||||
|
||||
printf("\n==== Testing centers.c/CenterRemove() ====\n");
|
||||
TestCenterRemove();
|
||||
printf("\n==== Testing centers.c/CenterRemove() ==== : OK\n");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
#include "../../include/base.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define KEY_ESCAPE 27
|
||||
#define KEY_DIRECTIONS 91
|
||||
#define KEY_ARROW_UP 65
|
||||
#define KEY_ARROW_DOWN 66
|
||||
#define KEY_ARROW_RIGHT 67
|
||||
#define KEY_ARROW_LEFT 68
|
||||
#define KEY_DELETE 127
|
||||
|
||||
#define C_CLEARSCREEN "\e[2J"
|
||||
#define C_CLEARLINE "\e[2K"
|
||||
#define C_CURSORLEFT "\e[1D"
|
||||
#define C_CURSORRIGHT "\e[1C"
|
||||
#define C_SAVE_CURSORPOS "\e7"
|
||||
#define C_RESTORE_CURSORPOS "\e8"
|
||||
#define C_COLOR_RED "\e[01;31m"
|
||||
#define C_COLOR_YELLOW "\e[00;33m"
|
||||
#define C_COLOR_GREEN "\e[00;32m"
|
||||
#define C_COLOR_BLUE "\e[01;34m"
|
||||
#define C_COLOR_REVERSE "\e[7m"
|
||||
#define C_COLOR_NORMAL "\e[0m"
|
||||
|
||||
//
|
||||
// Get a character code from the keyboard
|
||||
//
|
||||
static inline int getch(bool nonBlocking)
|
||||
{
|
||||
int buf = 0;
|
||||
// old terminal
|
||||
struct termios old = {0};
|
||||
|
||||
// force flush stdout
|
||||
fflush(stdout);
|
||||
|
||||
// Set non-blocking mode if asked
|
||||
if(nonBlocking)
|
||||
fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
|
||||
if(tcgetattr(0, &old) < 0) {
|
||||
printLog("%sError getting terminal settings! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
old.c_lflag &= ~ICANON; // disable buffered I/O
|
||||
old.c_lflag &= ~ECHO; // set no echo mode
|
||||
|
||||
if(tcsetattr(0, TCSANOW, &old) < 0) {
|
||||
printLog("%sError setting terminal settings! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = getchar();
|
||||
if(buf < 0) {
|
||||
// Check target busy (try again)
|
||||
if(errno == EAGAIN)
|
||||
return 0;
|
||||
|
||||
printLog("%sError reading character! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
old.c_lflag |= ICANON; // enable buffered I/O
|
||||
old.c_lflag |= ECHO; // set echo mode
|
||||
|
||||
if(tcsetattr(0, TCSADRAIN, &old) < 0) {
|
||||
printLog("%sError resetting terminal settings! (%s)\n",
|
||||
C_COLOR_RED,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Reset blocking mode
|
||||
if(nonBlocking)
|
||||
fcntl(0, F_SETFL, 0);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
|
||||
while(1) {
|
||||
int c = getch(1);
|
||||
|
||||
if (c > 0)
|
||||
printf("touche %d\n", c);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Local worker tests //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../localworker.c"
|
|
@ -1,23 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Scheduler tests //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../scheduler.c"
|
|
@ -1,23 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server tests //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../server.c"
|
|
@ -1,13 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int *a = malloc(7 * sizeof(int));
|
||||
|
||||
printf("Salut! Tableau d'entiers à l'adresse %p\n", a);
|
||||
|
||||
int *b = (int*) realloc(a, 8*sizeof(int));
|
||||
|
||||
printf("Salut! Tableau d'entiers à l'adresse %p\n", b);
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml2/libxml/xmlmemory.h>
|
||||
#include <libxml2/libxml/parser.h>
|
||||
|
||||
void parseStory (xmlDocPtr doc, xmlNodePtr cur)
|
||||
{
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL) {
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"authors"))) {
|
||||
printf("%s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void parseDoc(char *docname)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr cur;
|
||||
doc = xmlParseFile(docname);
|
||||
if (doc == NULL ) {
|
||||
fprintf(stderr,"Document not parsed successfully. \n");
|
||||
xmlFreeDoc(doc);
|
||||
return;
|
||||
}
|
||||
|
||||
cur = xmlDocGetRootElement(doc);
|
||||
if (cur == NULL) {
|
||||
fprintf(stderr,"empty document\n");
|
||||
xmlFreeDoc(doc);
|
||||
return;
|
||||
}
|
||||
if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
|
||||
fprintf(stderr,"document of the wrong type, root node != story");
|
||||
xmlFreeDoc(doc);
|
||||
return;
|
||||
}
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL) {
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){
|
||||
parseStory(doc, cur);
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
xmlFreeDoc(doc);
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *docname;
|
||||
if (argc <= 1) {
|
||||
printf("Usage: %s docname\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
docname = argv[1];
|
||||
parseDoc(docname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<story>
|
||||
<storyinfo>
|
||||
<author>John Fleck</author>
|
||||
<datewritten>June 2, 2002</datewritten>
|
||||
<keyword>example keyword</keyword>
|
||||
|
||||
</storyinfo>
|
||||
<body>
|
||||
<headline>This is the headline</headline>
|
||||
<para>This is the body text.</para>
|
||||
|
||||
</body>
|
||||
|
||||
</story>
|
43
src/worker.c
43
src/worker.c
|
@ -1,43 +0,0 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Local worker module //
|
||||
// //
|
||||
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
||||
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/worker.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
double truc;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
void worker_start(struct worker_t *self, struct scheduler_t *scheduler)
|
||||
{
|
||||
// Locking ressources
|
||||
#pragma omp critical
|
||||
{
|
||||
scheduler->n_workers++;
|
||||
//XXX lock space units
|
||||
}
|
||||
self->status = WORKER_NORMAL_EXIT;
|
||||
}
|
Loading…
Reference in New Issue