]>
git.ipfire.org Git - pakfire.git/blob - src/cli/lib/upload_create.c
f22c7ad0c01eca011d71d7602479909488d7f600
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/ctx.h>
27 #include "upload_create.h"
29 static const char* args_doc
= "FILES...";
31 static const char* doc
= "Uploads a file";
36 const char* files
[MAX_FILES
];
37 unsigned int num_files
;
40 static error_t
parse(int key
, char* arg
, struct argp_state
* state
, void* data
) {
41 struct config
* config
= data
;
45 if (config
->num_files
>= MAX_FILES
)
48 config
->files
[config
->num_files
++] = arg
;
52 return ARGP_ERR_UNKNOWN
;
58 int cli_upload_create(void* data
, int argc
, char* argv
[]) {
59 struct pakfire_buildservice
* service
= NULL
;
60 struct config config
= {};
63 struct pakfire_ctx
* ctx
= data
;
65 // Parse the command line
66 r
= cli_parse(NULL
, NULL
, args_doc
, doc
, parse
, argc
, argv
, &config
);
70 // Connect to the build service
71 r
= pakfire_buildservice_create(&service
, ctx
);
76 for (unsigned int i
= 0; i
< config
.num_files
; i
++) {
77 r
= pakfire_buildservice_upload(service
, config
.files
[i
], NULL
);
84 pakfire_buildservice_unref(service
);