···11+ GNU LESSER GENERAL PUBLIC LICENSE
22+ Version 3, 29 June 2007
33+44+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
55+ Everyone is permitted to copy and distribute verbatim copies
66+ of this license document, but changing it is not allowed.
77+88+99+ This version of the GNU Lesser General Public License incorporates
1010+the terms and conditions of version 3 of the GNU General Public
1111+License, supplemented by the additional permissions listed below.
1212+1313+ 0. Additional Definitions.
1414+1515+ As used herein, "this License" refers to version 3 of the GNU Lesser
1616+General Public License, and the "GNU GPL" refers to version 3 of the GNU
1717+General Public License.
1818+1919+ "The Library" refers to a covered work governed by this License,
2020+other than an Application or a Combined Work as defined below.
2121+2222+ An "Application" is any work that makes use of an interface provided
2323+by the Library, but which is not otherwise based on the Library.
2424+Defining a subclass of a class defined by the Library is deemed a mode
2525+of using an interface provided by the Library.
2626+2727+ A "Combined Work" is a work produced by combining or linking an
2828+Application with the Library. The particular version of the Library
2929+with which the Combined Work was made is also called the "Linked
3030+Version".
3131+3232+ The "Minimal Corresponding Source" for a Combined Work means the
3333+Corresponding Source for the Combined Work, excluding any source code
3434+for portions of the Combined Work that, considered in isolation, are
3535+based on the Application, and not on the Linked Version.
3636+3737+ The "Corresponding Application Code" for a Combined Work means the
3838+object code and/or source code for the Application, including any data
3939+and utility programs needed for reproducing the Combined Work from the
4040+Application, but excluding the System Libraries of the Combined Work.
4141+4242+ 1. Exception to Section 3 of the GNU GPL.
4343+4444+ You may convey a covered work under sections 3 and 4 of this License
4545+without being bound by section 3 of the GNU GPL.
4646+4747+ 2. Conveying Modified Versions.
4848+4949+ If you modify a copy of the Library, and, in your modifications, a
5050+facility refers to a function or data to be supplied by an Application
5151+that uses the facility (other than as an argument passed when the
5252+facility is invoked), then you may convey a copy of the modified
5353+version:
5454+5555+ a) under this License, provided that you make a good faith effort to
5656+ ensure that, in the event an Application does not supply the
5757+ function or data, the facility still operates, and performs
5858+ whatever part of its purpose remains meaningful, or
5959+6060+ b) under the GNU GPL, with none of the additional permissions of
6161+ this License applicable to that copy.
6262+6363+ 3. Object Code Incorporating Material from Library Header Files.
6464+6565+ The object code form of an Application may incorporate material from
6666+a header file that is part of the Library. You may convey such object
6767+code under terms of your choice, provided that, if the incorporated
6868+material is not limited to numerical parameters, data structure
6969+layouts and accessors, or small macros, inline functions and templates
7070+(ten or fewer lines in length), you do both of the following:
7171+7272+ a) Give prominent notice with each copy of the object code that the
7373+ Library is used in it and that the Library and its use are
7474+ covered by this License.
7575+7676+ b) Accompany the object code with a copy of the GNU GPL and this license
7777+ document.
7878+7979+ 4. Combined Works.
8080+8181+ You may convey a Combined Work under terms of your choice that,
8282+taken together, effectively do not restrict modification of the
8383+portions of the Library contained in the Combined Work and reverse
8484+engineering for debugging such modifications, if you also do each of
8585+the following:
8686+8787+ a) Give prominent notice with each copy of the Combined Work that
8888+ the Library is used in it and that the Library and its use are
8989+ covered by this License.
9090+9191+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
9292+ document.
9393+9494+ c) For a Combined Work that displays copyright notices during
9595+ execution, include the copyright notice for the Library among
9696+ these notices, as well as a reference directing the user to the
9797+ copies of the GNU GPL and this license document.
9898+9999+ d) Do one of the following:
100100+101101+ 0) Convey the Minimal Corresponding Source under the terms of this
102102+ License, and the Corresponding Application Code in a form
103103+ suitable for, and under terms that permit, the user to
104104+ recombine or relink the Application with a modified version of
105105+ the Linked Version to produce a modified Combined Work, in the
106106+ manner specified by section 6 of the GNU GPL for conveying
107107+ Corresponding Source.
108108+109109+ 1) Use a suitable shared library mechanism for linking with the
110110+ Library. A suitable mechanism is one that (a) uses at run time
111111+ a copy of the Library already present on the user's computer
112112+ system, and (b) will operate properly with a modified version
113113+ of the Library that is interface-compatible with the Linked
114114+ Version.
115115+116116+ e) Provide Installation Information, but only if you would otherwise
117117+ be required to provide such information under section 6 of the
118118+ GNU GPL, and only to the extent that such information is
119119+ necessary to install and execute a modified version of the
120120+ Combined Work produced by recombining or relinking the
121121+ Application with a modified version of the Linked Version. (If
122122+ you use option 4d0, the Installation Information must accompany
123123+ the Minimal Corresponding Source and Corresponding Application
124124+ Code. If you use option 4d1, you must provide the Installation
125125+ Information in the manner specified by section 6 of the GNU GPL
126126+ for conveying Corresponding Source.)
127127+128128+ 5. Combined Libraries.
129129+130130+ You may place library facilities that are a work based on the
131131+Library side by side in a single library together with other library
132132+facilities that are not Applications and are not covered by this
133133+License, and convey such a combined library under terms of your
134134+choice, if you do both of the following:
135135+136136+ a) Accompany the combined library with a copy of the same work based
137137+ on the Library, uncombined with any other library facilities,
138138+ conveyed under the terms of this License.
139139+140140+ b) Give prominent notice with the combined library that part of it
141141+ is a work based on the Library, and explaining where to find the
142142+ accompanying uncombined form of the same work.
143143+144144+ 6. Revised Versions of the GNU Lesser General Public License.
145145+146146+ The Free Software Foundation may publish revised and/or new versions
147147+of the GNU Lesser General Public License from time to time. Such new
148148+versions will be similar in spirit to the present version, but may
149149+differ in detail to address new problems or concerns.
150150+151151+ Each version is given a distinguishing version number. If the
152152+Library as you received it specifies that a certain numbered version
153153+of the GNU Lesser General Public License "or any later version"
154154+applies to it, you have the option of following the terms and
155155+conditions either of that published version or of any later version
156156+published by the Free Software Foundation. If the Library as you
157157+received it does not specify a version number of the GNU Lesser
158158+General Public License, you may choose any version of the GNU Lesser
159159+General Public License ever published by the Free Software Foundation.
160160+161161+ If the Library as you received it specifies that a proxy can decide
162162+whether future versions of the GNU Lesser General Public License shall
163163+apply, that proxy's public statement of acceptance of any version is
164164+permanent authorization for you to choose that version for the
165165+Library.
+103
src/quarantine/quarantine.c
···11+/*
22+ * Darling - libquarantine
33+ * Copyright (c) 2016 Lubos Dolezel, All rights reserved.
44+ *
55+ * This library is free software; you can redistribute it and/or
66+ * modify it under the terms of the GNU Lesser General Public
77+ * License as published by the Free Software Foundation; either
88+ * version 3.0 of the License, or (at your option) any later version.
99+ *
1010+ * This library is distributed in the hope that it will be useful,
1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313+ * Lesser General Public License for more details.
1414+ *
1515+ * You should have received a copy of the GNU Lesser General Public
1616+ * License along with this library.
1717+ */
1818+1919+#include "quarantine.h"
2020+#include <limits.h>
2121+#include <stdlib.h>
2222+#include <string.h>
2323+2424+const char* _qtn_xattr_name = "com.apple.quarantine";
2525+2626+static const char* error_strings[] = {
2727+ "Undefined error: 0",
2828+ "Item not quarantined",
2929+ "Quarantine is unavailable",
3030+ "Failed to load a compatible version of libMatch"
3131+};
3232+3333+struct _qtn_file_s
3434+{
3535+ char path[NAME_MAX];
3636+};
3737+3838+qtn_file_t _qtn_file_alloc()
3939+{
4040+ qtn_file_t f = (qtn_file_t) malloc(sizeof(struct _qtn_file_s));
4141+ memset(f, 0, sizeof(*f));
4242+ return f;
4343+}
4444+4545+void _qtn_file_free(qtn_file_t f)
4646+{
4747+ free(f);
4848+}
4949+5050+qtn_file_t _qtn_file_clone(qtn_file_t f)
5151+{
5252+ qtn_file_t rv = _qtn_file_alloc();
5353+ memcpy(rv, f, sizeof(*rv));
5454+ return rv;
5555+}
5656+5757+int _qtn_file_init_with_fd(qtn_file_t file, int fd)
5858+{
5959+ return QTN_NOT_QUARANTINED;
6060+}
6161+6262+int _qtn_file_apply_to_fd(qtn_file_t file, int fd)
6363+{
6464+ return QTN_NOT_QUARANTINED;
6565+}
6666+6767+int _qtn_file_apply_to_path(qtn_file_t file, const char* path)
6868+{
6969+ return QTN_NOT_QUARANTINED;
7070+}
7171+7272+int _qtn_file_init_with_path(qtn_file_t file, const char *path)
7373+{
7474+ return QTN_NOT_QUARANTINED;
7575+}
7676+7777+int _qtn_file_init_with_data(qtn_file_t file, const void *data, size_t len)
7878+{
7979+ return QTN_NOT_QUARANTINED;
8080+}
8181+8282+int _qtn_file_to_data(qtn_file_t file, void * data, size_t* len)
8383+{
8484+ return QTN_NOT_QUARANTINED;
8585+}
8686+8787+const char *_qtn_error(int err)
8888+{
8989+ if (err >= 0 || -err >= sizeof(error_strings)/sizeof(error_strings[0]))
9090+ return strerror(err);
9191+ return error_strings[-err];
9292+}
9393+9494+int _qtn_file_set_flags(qtn_file_t file, uint32_t flags)
9595+{
9696+ return 0;
9797+}
9898+9999+uint32_t _qtn_file_get_flags(qtn_file_t file)
100100+{
101101+ return 0;
102102+}
103103+
+72
src/quarantine/quarantine.h
···11+/*
22+ * Darling - libquarantine
33+ * Copyright (c) 2016 Lubos Dolezel, All rights reserved.
44+ *
55+ * This library is free software; you can redistribute it and/or
66+ * modify it under the terms of the GNU Lesser General Public
77+ * License as published by the Free Software Foundation; either
88+ * version 3.0 of the License, or (at your option) any later version.
99+ *
1010+ * This library is distributed in the hope that it will be useful,
1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313+ * Lesser General Public License for more details.
1414+ *
1515+ * You should have received a copy of the GNU Lesser General Public
1616+ * License along with this library.
1717+ */
1818+1919+#ifndef _QUARANTINE_H_
2020+#define _QUARANTINE_H_
2121+2222+#include <stdint.h>
2323+#include <stddef.h>
2424+2525+#define QTN_NOT_QUARANTINED (-1)
2626+2727+typedef struct _qtn_file_s *qtn_file_t;
2828+2929+extern qtn_file_t _qtn_file_alloc();
3030+extern void _qtn_file_free(qtn_file_t file);
3131+3232+extern qtn_file_t _qtn_file_clone(qtn_file_t file);
3333+3434+extern int _qtn_file_init_with_fd(qtn_file_t file, int fd);
3535+extern int _qtn_file_apply_to_fd(qtn_file_t file, int fd);
3636+extern int _qtn_file_apply_to_path(qtn_file_t file, const char* path);
3737+3838+extern int _qtn_file_init_with_path(qtn_file_t file, const char *path);
3939+4040+extern int _qtn_file_init_with_data(qtn_file_t file, const void *, size_t);
4141+extern int _qtn_file_to_data(qtn_file_t file, void *, size_t*);
4242+extern int _qtn_file_set_flags(qtn_file_t file, uint32_t flags);
4343+extern uint32_t _qtn_file_get_flags(qtn_file_t file);
4444+4545+extern const char *_qtn_error(int err);
4646+4747+extern const char *_qtn_xattr_name;
4848+4949+#define QTN_SERIALIZED_DATA_MAX 4096
5050+5151+#define qtn_file_alloc _qtn_file_alloc
5252+#define qtn_file_free _qtn_file_free
5353+5454+#define qtn_file_clone _qtn_file_clone
5555+#define qtn_file_set_flags _qtn_file_set_flags
5656+#define qtn_file_get_flags _qtn_file_get_flags
5757+5858+#define qtn_file_init_with_fd _qtn_file_init_with_fd
5959+#define qtn_file_apply_to_fd _qtn_file_apply_to_fd
6060+#define qtn_file_apply_to_path _qtn_file_apply_to_path
6161+6262+#define qtn_file_init_with_path _qtn_file_init_with_path
6363+6464+#define qtn_file_init_with_data _qtn_file_init_with_data
6565+#define qtn_file_to_data _qtn_file_to_data
6666+6767+#define qtn_error _qtn_error
6868+6969+#define qtn_xattr_name _qtn_xattr_name
7070+7171+#endif
7272+