* Several changes to the compilation of Alpine in Windows to use
[alpine.git] / imap / src / osdep / nt / proc.c
blob8fc3c4eef6dc80f5ced405e45ed429542326e959
1 /*
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
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <ctype.h>
17 int main(int, char **);
19 int
20 main(int argc, char *argv[])
22 int rv = 0, i;
23 FILE *fph, *fpc, *fpa;
24 char *opt;
26 fph = fpc = fpa = NULL;
27 if(argc < 2){
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");
31 exit(1);
34 opt = argv[1];
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",
41 argv[i], argv[i]);
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",
51 argv[i], argv[i]);
52 fprintf(fpa, "#include \"auth_%s.c\"\n", argv[i]);
55 else if(!strcmp(opt, "setproto")){
56 if(argc != 4){
57 fprintf(stdout, "setproto requires two additional arguments\n");
58 exit(1);
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);");
72 else {
73 fprintf(stdout, "Try: \"drivers\", \"mkauths\", \"setproto\", \"sslinit\", or \"version\".\n");
74 exit(1);
76 if(fpa != NULL) fclose(fpa);
77 if(fpc != NULL) fclose(fpc);
78 if(fph != NULL) fclose(fph);
79 exit(0);