-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgc_printer.c
51 lines (40 loc) · 1.35 KB
/
gc_printer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021-2022 HandsomeMod Project
*
* Handsomeyingyan <[email protected]>
*
* GC(Gadget Controller) is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*/
#include "gc_printer.h"
int gc_printer_create(int argc,char *argv[],gc_generic_info info)
{
usbg_gadget *gadget = gc_init(info);
if(gadget == NULL)
return GC_FAILED;
usbg_function *f_printer;
int usbg_ret;
char *id = gc_generate_id(USBG_F_PRINTER);
if(id == NULL)
return GC_FAILED;
usbg_ret = usbg_create_function(gadget,USBG_F_PRINTER,id,NULL,&f_printer);
if(usbg_ret != USBG_SUCCESS){
fprintf(stderr,"failed to create printer function! (maybe kernel module not loaded?)\n");
gc_clean();
return GC_FAILED;
}
/* for now we only create one config file */
usbg_config *config = gc_get_config(gadget);
usbg_ret = usbg_add_config_function(config,id,f_printer);
if(usbg_ret != USBG_SUCCESS){
fprintf(stderr,"failed to bind printer config to function! \n");
gc_clean();
return GC_FAILED;
}
gc_clean();
return GC_SUCCESS;
}