Browse Source

work around for protoc cmake stuff

configuration
Lennart Weller 9 years ago
parent
commit
2bfcf08c5e
5 changed files with 15 additions and 12 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -0
      cmake/FindProtobufC.cmake
  3. +3
    -2
      src/CMakeLists.txt
  4. +8
    -8
      src/config.c
  5. +2
    -2
      src/gog.h

+ 1
- 0
.gitignore View File

@ -1,6 +1,7 @@
*.o
*.pb-c.*
*.swp
*.pbf
goglogin
src/token.h
src/generated/*


+ 1
- 0
cmake/FindProtobufC.cmake View File

@ -53,6 +53,7 @@ function(PROTOC VAR)
COMMENT "Running protocol buffer compiler on ${FIL}"
VERBATIM
)
set_source_files_properties(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)
endforeach(FIL)
set(${VAR} ${${VAR}} PARENT_SCOPE)


+ 3
- 2
src/CMakeLists.txt View File

@ -16,8 +16,9 @@ set(GOG_SRC gog.h
serialization.c
config.c
)
protoc(PROTO_SRC state.proto config.proto)
add_executable(goglogin ${GOG_SRC} ${PROTO_SRC})
protoc(STATE_SRC state.proto)
protoc(CONFIG_SRC config.proto)
add_executable(goglogin ${GOG_SRC} ${STATE_SRC} ${CONFIG_SRC})
target_link_libraries(goglogin ${LIBS})
install(TARGETS goglogin DESTINATION bin)


+ 8
- 8
src/config.c View File

@ -1,13 +1,13 @@
#include "gog.h"
#include "config.pb-c.h"
int load_config(char *path) {
int load_config() {
FILE *cfg_file;
Config *cfg;
off_t len;
void *buf;
if((cfg_file = fopen(path, "r"))) {
if((cfg_file = fopen(config.config_file, "r"))) {
fseek(cfg_file, 0, SEEK_END);
len = ftell(cfg_file);
buf = malloc(len);
@ -28,16 +28,16 @@ int load_config(char *path) {
}
return 0;
}
int save_config(char *path) {
int save_config() {
FILE *cfg_file;
Config cfg = INIT__CONFIG;
Config cfg = CONFIG__INIT;
void *buf;
off_t len;
if((cfg_file = fopen(path, "w+"))) {
cfg.token = &config.token;
cfg.secret = &config.secret;
cfg.download_path = &config.download_path;
if((cfg_file = fopen(config.config_file, "w+"))) {
cfg.token = config.token;
cfg.secret = config.secret;
cfg.download_path = config.download_path;
len = config__get_packed_size(&cfg);
buf = malloc(len);


+ 2
- 2
src/gog.h View File

@ -214,8 +214,8 @@ int deserialize_download(void **data, struct download_t **out);
int deserialize_file(char *file, struct download_t **out);
/* config.c */
int load_config(char *path);
int save_config(char *path);
int load_config();
int save_config();
/* api.c */
/** \brief Downloads the gog api configuration containing all urls


Loading…
Cancel
Save