2 * Copyright 2018 Eduardo Chappa
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
17 int main(int, char **);
20 main(int argc
, char *argv
[])
23 FILE *fph
, *fpc
, *fpa
;
26 fph
= fpc
= fpa
= NULL
;
28 fprintf(stdout
, "Not enough arguments.\n");
29 fprintf(stdout
, "Usage: %s opt ...\n", argv
[0]);
30 fprintf(stdout
, "opt can be drivers, mkauths, version, setproto or sslinit\n");
35 if(!strcmp(opt
, "drivers")){
36 fph
= fopen("linkage.h", "w");
37 fpc
= fopen("linkage.c", "w");
38 for (i
= 2; i
< argc
; i
++){
39 fprintf(fph
, "extern DRIVER %sdriver;\n", argv
[i
]);
40 fprintf(fpc
, " mail_link (&%sdriver); /* link in the %s driver */\n",
44 else if(!strcmp(opt
, "mkauths")){
45 fph
= fopen("linkage.h", "a");
46 fpc
= fopen("linkage.c", "a");
47 fpa
= fopen("auths.c", "w");
48 for (i
= 2; i
< argc
; i
++){
49 fprintf(fph
, "extern AUTHENTICATOR auth_%s;\n", argv
[i
]);
50 fprintf(fpc
, " auth_link (&auth_%s); /* link in the %s authenticator */\n",
52 fprintf(fpa
, "#include \"auth_%s.c\"\n", argv
[i
]);
55 else if(!strcmp(opt
, "setproto")){
57 fprintf(stdout
, "setproto requires two additional arguments\n");
60 fph
= fopen("linkage.h", "a");
61 fprintf(fph
, "#define CREATEPROTO %sproto\n", argv
[2]);
62 fprintf(fph
, "#define APPENDPROTO %sproto\n", argv
[3]);
64 else if(!strcmp(opt
, "sslinit")){
65 fpc
= fopen("linkage.c", "a");
66 fprintf(fpc
, "%s\n", "ssl_onceonlyinit();");
68 else if(!strcmp(opt
, "version")){
69 fpc
= fopen("linkage.c", "a");
70 fprintf(fpc
, "%s\n", "mail_versioncheck(CCLIENTVERSION);");
73 fprintf(stdout
, "Try: \"drivers\", \"mkauths\", \"setproto\", \"sslinit\", or \"version\".\n");
76 if(fpa
!= NULL
) fclose(fpa
);
77 if(fpc
!= NULL
) fclose(fpc
);
78 if(fph
!= NULL
) fclose(fph
);