1 | /*
|
---|
2 | * TOPPERS PROJECT Home Network Working Group Software
|
---|
3 | *
|
---|
4 | * Copyright (C) 2016-2019 Cores Co., Ltd. Japan
|
---|
5 | *
|
---|
6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
11 | * スコード中に含まれていること.
|
---|
12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
15 | * の無保証規定を掲載すること.
|
---|
16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
18 | * と.
|
---|
19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
22 | * 報告すること.
|
---|
23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
27 | * 免責すること.
|
---|
28 | *
|
---|
29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
33 | * の責任を負わない.
|
---|
34 | *
|
---|
35 | * @(#) $Id$
|
---|
36 | */
|
---|
37 |
|
---|
38 | #ifndef _CLIENT_H_
|
---|
39 | #define _CLIENT_H_
|
---|
40 |
|
---|
41 | typedef struct client_info_t {
|
---|
42 | char client_id[80];
|
---|
43 | //char project_id[32];
|
---|
44 | //char auth_uri[64];
|
---|
45 | //char token_uri[48];
|
---|
46 | //char auth_provider_x509_cert_url[48];
|
---|
47 | char client_secret[32];
|
---|
48 | //char redirect_uris[2][32];
|
---|
49 | } client_info_t;
|
---|
50 |
|
---|
51 | typedef struct credential_t {
|
---|
52 | char device_code[100];
|
---|
53 | char user_code[12];
|
---|
54 | int expires_in;
|
---|
55 | int interval;
|
---|
56 | char verification_url[32];
|
---|
57 | char access_token[132];
|
---|
58 | char refresh_token[64];
|
---|
59 | char scope[64];
|
---|
60 | char token_type[16];
|
---|
61 | } credential_t;
|
---|
62 |
|
---|
63 | typedef struct error_response_t {
|
---|
64 | char error[64];
|
---|
65 | char error_description[64];
|
---|
66 | } error_response_t;
|
---|
67 |
|
---|
68 | typedef struct drive_file_t {
|
---|
69 | char kind[32];
|
---|
70 | char id[36];
|
---|
71 | char name[256];
|
---|
72 | char mimeType[40];
|
---|
73 | } drive_file_t;
|
---|
74 |
|
---|
75 | typedef enum google_drive_parse_state_t {
|
---|
76 | psRoot,
|
---|
77 | psInstalled,
|
---|
78 | psClientId,
|
---|
79 | psProjectId,
|
---|
80 | psAuthUri,
|
---|
81 | psTokenUri,
|
---|
82 | psAuthProviderX509CertUrl,
|
---|
83 | psClientSecret,
|
---|
84 | psRedirectUris,
|
---|
85 | psDeviceCode,
|
---|
86 | psUserCode,
|
---|
87 | psExpiresIn,
|
---|
88 | psInterval,
|
---|
89 | psVerificationUrl,
|
---|
90 | psAccessToken,
|
---|
91 | psRefreshToken,
|
---|
92 | psScope,
|
---|
93 | psTokenType,
|
---|
94 | psKind,
|
---|
95 | psId,
|
---|
96 | psName,
|
---|
97 | psMimeType,
|
---|
98 | psError,
|
---|
99 | psErrorDescription,
|
---|
100 | } google_drive_parse_state_t;
|
---|
101 |
|
---|
102 | struct jsonsl_st;
|
---|
103 | typedef struct jsonsl_st *jsonsl_t;
|
---|
104 |
|
---|
105 | typedef void (*parser_callback_t)(struct google_drive_t *gd, struct jsonsl_state_st *state, const char *buf);
|
---|
106 |
|
---|
107 | typedef struct google_drive_t {
|
---|
108 | client_info_t client_info;
|
---|
109 | credential_t credential;
|
---|
110 | drive_file_t file;
|
---|
111 | error_response_t error;
|
---|
112 | jsonsl_t jsn;
|
---|
113 | google_drive_parse_state_t state;
|
---|
114 | int index;
|
---|
115 | char fname[sizeof("1:/log/20160101000000.log")];
|
---|
116 | char jsn_buf[256];
|
---|
117 | int jsn_buf_pos;
|
---|
118 | parser_callback_t start;
|
---|
119 | parser_callback_t end;
|
---|
120 | } google_drive_t;
|
---|
121 |
|
---|
122 | extern google_drive_t google_drive;
|
---|
123 |
|
---|
124 | void client_init(void);
|
---|
125 | void client_final(void);
|
---|
126 |
|
---|
127 | void client_set_client_id(const char *client_id);
|
---|
128 | void client_set_client_secret(const char *client_secret);
|
---|
129 | int client_get_device_id(int argc, char **argv);
|
---|
130 | int client_get_access_token(int argc, char **argv);
|
---|
131 | int client_update_access_token(int argc, char **argv);
|
---|
132 | int client_revoke(int argc, char **argv);
|
---|
133 | int client_upload_file(int argc, char **argv);
|
---|
134 |
|
---|
135 | #endif /* _CLIENT_H_ */
|
---|