aboutsummaryrefslogblamecommitdiffstats
path: root/src/actions.h
blob: 2015538998223caeb7d283f98f8d85b540f131ac (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                                                


                                             
                                                                                
  

                                          
  

                                                                                

                                                         

                                                                                


                 
                   
                     


                                                 
                                      


          




                       
                                    



                                 
                       



                
 


                
          

               
  
                                
 




                    
                                        




                                   
              
           
            


          
























                                                       
                      
/* actions.h - ck actions ----------------------------------------------*- C -*-
 *
 * This file is part of ck, the config keeper
 *
 * -----------------------------------------------------------------------------
 *
 * Copyright (C) 2018  Anastasis Grammenos
 * GPLv3 (see LICENCE for the full notice)
 *
 * -----------------------------------------------------------------------------
 *
 * The various structs actions use to keep track of their
 * specific options and the run_ACTION routines.
 *
 * -------------------------------------------------------------------------- */
#ifndef ACTIONS_H
#define ACTIONS_H

#include "ckutil.h"
#include "clparser.h"
#include "confparser.h"

#define X(ACTION)                               \
  int run_##ACTION(UserOpt *, Conf *);
CK_ACTIONS
#undef X

enum AddOptErrors {
  ADD_NO_ERR = 0,
  ADD_ERR_WRONG_CONFIG,
  ADD_ERR_WRONG_FLAGS
};
typedef enum AddOptErrors AddOptErr;

typedef struct AddOptions AddOpt;
struct AddOptions {
  char *progName;
  char confPath[STR_L];
  int secret;
  int prime;
  AddOptErr err;
};

enum ListTypes {
  LT_PATH,
  LT_PROGRAM,
  LT_TREE,
  LT_CKCONF,
  LT_PROG_CONFS
};
typedef enum ListTypes ListType;

enum ListShowTypes {
   LST_PLAIN,
   LST_LISP,
   LST_PYTHON,
};
typedef enum ListShowTypes ListShowType;

typedef struct ListOptions ListOpt;
struct ListOptions {
  ListType _lt;
  ListShowType _lst;
  char *pName;
  int attr;
  int bName;
  int err;
};

/* init.c */
int init_create_config_file(UserOpt *opt);

/* add.c */
AddOpt add_make_options(cklist *args);
void add_print_opts(AddOpt *opt);
int add_make_link(const AddOpt *opt, const Conf *conf);

/* list.c */
ListOpt list_make_options(cklist *args);

/* restore.c */
int restore_make_links(cklist *from, cklist *to);

/************************/
/* PRINT RESULTS & HELP */
/************************/
#define X(ACTION)                        \
  void print_##ACTION##_help(void);
CK_ACTIONS
#undef X

void print_conf_help(void);
void print_verbose_help(void);

#endif /* ACTIONS_H */