Pharos
0.7.23
Modern Web Framework & Web App Hosting Service.
Toggle main menu visibility
Loading...
Searching...
No Matches
native_barcode_runtime_ops.c
Go to the documentation of this file.
1
#include "
native_barcode_runtime_ops.h
"
2
3
#include "
native_barcode_decode.h
"
4
#include "
native_support.h
"
5
6
#include <stdio.h>
7
#include <stdlib.h>
8
9
int
handle_native_barcode_command
(
int
argc,
char
**argv) {
10
char
*decoded_text = NULL;
11
int
code = 0;
12
13
if
(argc < 2 || argv == NULL || argv[0] == NULL || argv[1] == NULL) {
14
return
78;
15
}
16
if
(!
streq
(argv[0],
"barcode"
) || !
streq
(argv[1],
"decode"
)) {
17
return
78;
18
}
19
if
(argc != 3 || argv[2] == NULL || argv[2][0] ==
'\0'
) {
20
fprintf(stderr,
"usage: pharos barcode decode IMAGE_PATH\n"
);
21
return
64;
22
}
23
if
(!
path_exists
(argv[2])) {
24
fprintf(stderr,
"image file not found: %s\n"
, argv[2]);
25
return
66;
26
}
27
28
code =
native_barcode_decode_image_path
(argv[2], &decoded_text);
29
if
(code == 0) {
30
if
(decoded_text == NULL) {
31
return
69;
32
}
33
printf(
"%s"
, decoded_text);
34
free(decoded_text);
35
return
0;
36
}
37
38
if
(code == 69 && !
native_barcode_decoder_is_direct_linked
()) {
39
fprintf(stderr,
"native barcode decode unavailable: rebuild with PHAROS_ENABLE_NATIVE_ZXING=1 for a host-supported target\n"
);
40
}
41
free(decoded_text);
42
return
code;
43
}
native_barcode_decode_image_path
int native_barcode_decode_image_path(const char *image_path, char **decoded_text_out)
Definition
native_barcode_decode.c:21
native_barcode_decoder_is_direct_linked
int native_barcode_decoder_is_direct_linked(void)
Definition
native_barcode_decode.c:13
native_barcode_decode.h
handle_native_barcode_command
int handle_native_barcode_command(int argc, char **argv)
Definition
native_barcode_runtime_ops.c:9
native_barcode_runtime_ops.h
streq
int streq(const char *a, const char *b)
Tests whether two strings are exactly equal.
Definition
native_support.c:111
path_exists
int path_exists(const char *path)
Tests whether a filesystem path currently exists.
Definition
native_support.c:168
native_support.h
Declares shared low-level support helpers used across the Pharos native runtime.
src
native_runtime
c
native_barcode_runtime_ops.c
Generated by
1.17.0