]>
git.ipfire.org Git - people/ms/pakfire.git/blob - src/cli/lib/upload_delete.c
1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2023 Pakfire development team #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 #############################################################################*/
23 #include <pakfire/buildservice.h>
24 #include <pakfire/util.h>
28 #include "upload_delete.h"
30 static const char* args_doc
= "FILES...";
32 static const char* doc
= "Deletes an uploaded file";
34 #define MAX_UPLOADS 32
37 const char* uploads
[MAX_UPLOADS
];
38 unsigned int num_uploads
;
41 static error_t
parse(int key
, char* arg
, struct argp_state
* state
, void* data
) {
42 struct config
* config
= data
;
46 if (config
->num_uploads
>= MAX_UPLOADS
)
50 if (!pakfire_uuid_is_valid(arg
))
51 argp_error(state
, "Invalid UUID");
53 config
->uploads
[config
->num_uploads
++] = arg
;
57 return ARGP_ERR_UNKNOWN
;
63 int cli_upload_delete(void* data
, int argc
, char* argv
[]) {
64 struct pakfire_buildservice
* service
= NULL
;
65 struct config config
= {};
68 struct cli_config
* cli_config
= data
;
70 // Parse the command line
71 r
= cli_parse(NULL
, NULL
, args_doc
, doc
, parse
, 0, argc
, argv
, &config
);
75 // Connect to the build service
76 r
= pakfire_buildservice_create(&service
, cli_config
->ctx
);
81 for (unsigned int i
= 0; i
< config
.num_uploads
; i
++) {
82 r
= pakfire_buildservice_delete_upload(service
, config
.uploads
[i
]);
89 pakfire_buildservice_unref(service
);