diff --git a/driver/apdu/at.c b/driver/apdu/at.c index 2594cfe..d2c9cb7 100644 --- a/driver/apdu/at.c +++ b/driver/apdu/at.c @@ -222,7 +222,7 @@ static void libapduinterface_fini(void) { } -const struct lpac_driver driver_apdu_at = { +const struct euicc_driver driver_apdu_at = { .type = DRIVER_APDU, .name = "at", .init = (int (*)(void *))libapduinterface_init, diff --git a/driver/apdu/at.h b/driver/apdu/at.h index 1105d24..65a7767 100644 --- a/driver/apdu/at.h +++ b/driver/apdu/at.h @@ -1,4 +1,4 @@ #pragma once #include -extern const struct lpac_driver driver_apdu_at; +extern const struct euicc_driver driver_apdu_at; diff --git a/driver/apdu/gbinder_hidl.c b/driver/apdu/gbinder_hidl.c index 9748def..27cd6e5 100644 --- a/driver/apdu/gbinder_hidl.c +++ b/driver/apdu/gbinder_hidl.c @@ -318,7 +318,7 @@ static void libapduinterface_fini(void) { } -const struct lpac_driver driver_apdu_gbinder_hidl = { +const struct euicc_driver driver_apdu_gbinder_hidl = { .type = DRIVER_APDU, .name = "gbinder_hidl", .init = libapduinterface_init, diff --git a/driver/apdu/gbinder_hidl.h b/driver/apdu/gbinder_hidl.h index 5907fa0..0b03bb5 100644 --- a/driver/apdu/gbinder_hidl.h +++ b/driver/apdu/gbinder_hidl.h @@ -1,4 +1,4 @@ #pragma once #include -extern const struct lpac_driver driver_apdu_gbinder_hidl; +extern const struct euicc_driver driver_apdu_gbinder_hidl; diff --git a/driver/apdu/pcsc.c b/driver/apdu/pcsc.c index b78e979..ee7feed 100644 --- a/driver/apdu/pcsc.c +++ b/driver/apdu/pcsc.c @@ -457,7 +457,7 @@ static void libapduinterface_fini(void) { } -const struct lpac_driver driver_apdu_pcsc = { +const struct euicc_driver driver_apdu_pcsc = { .type = DRIVER_APDU, .name = "pcsc", .init = (int (*)(void *))libapduinterface_init, diff --git a/driver/apdu/pcsc.h b/driver/apdu/pcsc.h index 56f2cc9..e83c0e1 100644 --- a/driver/apdu/pcsc.h +++ b/driver/apdu/pcsc.h @@ -1,4 +1,4 @@ #pragma once #include -extern const struct lpac_driver driver_apdu_pcsc; +extern const struct euicc_driver driver_apdu_pcsc; diff --git a/driver/apdu/stdio.c b/driver/apdu/stdio.c index 188aebb..9c513aa 100644 --- a/driver/apdu/stdio.c +++ b/driver/apdu/stdio.c @@ -344,7 +344,7 @@ static void libapduinterface_fini(void) { } -const struct lpac_driver driver_apdu_stdio = { +const struct euicc_driver driver_apdu_stdio = { .type = DRIVER_APDU, .name = "stdio", .init = (int (*)(void *))libapduinterface_init, diff --git a/driver/apdu/stdio.h b/driver/apdu/stdio.h index c507020..a9ad2dc 100644 --- a/driver/apdu/stdio.h +++ b/driver/apdu/stdio.h @@ -1,4 +1,4 @@ #pragma once #include -extern const struct lpac_driver driver_apdu_stdio; +extern const struct euicc_driver driver_apdu_stdio; diff --git a/driver/driver.c b/driver/driver.c index cd67d01..928e428 100644 --- a/driver/driver.c +++ b/driver/driver.c @@ -2,7 +2,6 @@ #include "driver.private.h" #include -#include #include #ifdef LPAC_WITH_APDU_GBINDER @@ -21,7 +20,7 @@ #include "driver/apdu/stdio.h" #include "driver/http/stdio.h" -static const struct lpac_driver *drivers[] = { +static const struct euicc_driver *drivers[] = { #ifdef LPAC_WITH_APDU_GBINDER &driver_apdu_gbinder_hidl, #endif @@ -39,19 +38,19 @@ static const struct lpac_driver *drivers[] = { NULL, }; -static const struct lpac_driver *_driver_apdu = NULL; -static const struct lpac_driver *_driver_http = NULL; +static const struct euicc_driver *_driver_apdu = NULL; +static const struct euicc_driver *_driver_http = NULL; struct euicc_apdu_interface euicc_driver_interface_apdu; struct euicc_http_interface euicc_driver_interface_http; int (*euicc_driver_main_apdu)(int argc, char **argv) = NULL; int (*euicc_driver_main_http)(int argc, char **argv) = NULL; -static const struct lpac_driver *_find_driver(enum lpac_driver_type type, const char *name) +static const struct euicc_driver *_find_driver(enum euicc_driver_type type, const char *name) { for (int i = 0; drivers[i] != NULL; i++) { - const struct lpac_driver *d = drivers[i]; + const struct euicc_driver *d = drivers[i]; if (d->type != type) { continue; @@ -68,16 +67,16 @@ static const struct lpac_driver *_find_driver(enum lpac_driver_type type, const return NULL; } -int euicc_driver_init() +int euicc_driver_init(const char *apdu_driver_name, const char *http_driver_name) { - _driver_apdu = _find_driver(DRIVER_APDU, getenv("LPAC_APDU")); + _driver_apdu = _find_driver(DRIVER_APDU, apdu_driver_name); if (_driver_apdu == NULL) { fprintf(stderr, "No APDU driver found\n"); return -1; } - _driver_http = _find_driver(DRIVER_HTTP, getenv("LPAC_HTTP")); + _driver_http = _find_driver(DRIVER_HTTP, http_driver_name); if (_driver_http == NULL) { fprintf(stderr, "No HTTP driver found\n"); diff --git a/driver/driver.h b/driver/driver.h index 512049d..9ddadd5 100644 --- a/driver/driver.h +++ b/driver/driver.h @@ -8,5 +8,5 @@ extern struct euicc_http_interface euicc_driver_interface_http; extern int (*euicc_driver_main_apdu)(int argc, char **argv); extern int (*euicc_driver_main_http)(int argc, char **argv); -int euicc_driver_init(void); +int euicc_driver_init(const char *apdu_driver_name, const char *http_driver_name); void euicc_driver_fini(void); diff --git a/driver/driver.private.h b/driver/driver.private.h index 44b99c0..d1686d3 100644 --- a/driver/driver.private.h +++ b/driver/driver.private.h @@ -1,17 +1,16 @@ #pragma once -enum lpac_driver_type +enum euicc_driver_type { DRIVER_APDU, DRIVER_HTTP, }; -struct lpac_driver +struct euicc_driver { - enum lpac_driver_type type; + enum euicc_driver_type type; const char *name; int (*init)(void *interface); int (*main)(int argc, char **argv); void (*fini)(void); }; - diff --git a/driver/http/curl.c b/driver/http/curl.c index 78b9a8e..c237485 100644 --- a/driver/http/curl.c +++ b/driver/http/curl.c @@ -196,7 +196,7 @@ static void libhttpinterface_fini(void) { } -const struct lpac_driver driver_http_curl = { +const struct euicc_driver driver_http_curl = { .type = DRIVER_HTTP, .name = "curl", .init = (int (*)(void *))libhttpinterface_init, diff --git a/driver/http/curl.h b/driver/http/curl.h index b070a58..64156b4 100644 --- a/driver/http/curl.h +++ b/driver/http/curl.h @@ -1,4 +1,4 @@ #pragma once #include -extern const struct lpac_driver driver_http_curl; +extern const struct euicc_driver driver_http_curl; diff --git a/driver/http/stdio.c b/driver/http/stdio.c index 9044c5e..f0ca865 100644 --- a/driver/http/stdio.c +++ b/driver/http/stdio.c @@ -276,7 +276,7 @@ static void libhttpinterface_fini(void) { } -const struct lpac_driver driver_http_stdio = { +const struct euicc_driver driver_http_stdio = { .type = DRIVER_HTTP, .name = "stdio", .init = (int (*)(void *))libhttpinterface_init, diff --git a/driver/http/stdio.h b/driver/http/stdio.h index c6b9836..cdc5213 100644 --- a/driver/http/stdio.h +++ b/driver/http/stdio.h @@ -1,4 +1,4 @@ #pragma once #include -extern const struct lpac_driver driver_http_stdio; +extern const struct euicc_driver driver_http_stdio; diff --git a/src/main.c b/src/main.c index 79606f6..967422e 100644 --- a/src/main.c +++ b/src/main.c @@ -15,22 +15,17 @@ #include "applet/notification.h" #include "applet/version.h" -static struct applet_entry applet_apdu = { - .name = "apdu", - .main = NULL, -}; -static struct applet_entry applet_http = { - .name = "http", - .main = NULL, -}; - static int driver_applet_main(int argc, char **argv) { - applet_apdu.main = euicc_driver_main_apdu; - applet_http.main = euicc_driver_main_http; - static const struct applet_entry *applets[] = { - &applet_apdu, - &applet_http, + const struct applet_entry *applets[] = { + &(struct applet_entry){ + .name = "apdu", + .main = euicc_driver_main_apdu, + }, + &(struct applet_entry){ + .name = "http", + .main = euicc_driver_main_http, + }, NULL, }; return applet_entry(argc, argv, applets); @@ -79,7 +74,7 @@ int main(int argc, char **argv) memset(&euicc_ctx, 0, sizeof(euicc_ctx)); - if (euicc_driver_init()) + if (euicc_driver_init(getenv("LPAC_APDU"), getenv("LPAC_HTTP"))) { return -1; }