11 #if TIME_WITH_SYS_TIME
12 # include <sys/time.h>
16 # include <sys/time.h>
23 #include <libcitadel.h>
28 /* our directories... */
29 char ctdl_home_directory
[PATH_MAX
] = "";
30 char ctdl_bio_dir
[PATH_MAX
]="bio";
31 char ctdl_bb_dir
[PATH_MAX
]="bitbucket";
32 char ctdl_data_dir
[PATH_MAX
]="data";
33 char ctdl_dspam_dir
[PATH_MAX
]="dspam";
34 char ctdl_file_dir
[PATH_MAX
]="files";
35 char ctdl_hlp_dir
[PATH_MAX
]="help";
36 char ctdl_image_dir
[PATH_MAX
]="images";
37 char ctdl_info_dir
[PATH_MAX
]="info";
38 char ctdl_key_dir
[PATH_MAX
]=SSL_DIR
;
39 char ctdl_message_dir
[PATH_MAX
]="messages";
40 char ctdl_usrpic_dir
[PATH_MAX
]="userpics";
41 char ctdl_bbsbase_dir
[PATH_MAX
]="";
42 char ctdl_etc_dir
[PATH_MAX
]="";
43 /* attention! this may be non volatile on some oses */
44 char ctdl_run_dir
[PATH_MAX
]="";
45 char ctdl_spool_dir
[PATH_MAX
]="network";
46 char ctdl_netout_dir
[PATH_MAX
]="network/spoolout";
47 char ctdl_netin_dir
[PATH_MAX
]="network/spoolin";
48 char ctdl_netcfg_dir
[PATH_MAX
]="netconfigs";
49 char ctdl_utilbin_dir
[PATH_MAX
]="";
50 char ctdl_sbin_dir
[PATH_MAX
]="";
51 char ctdl_bin_dir
[PATH_MAX
]="";
53 /* some of our files, that are needed in several places */
54 char file_citadel_control
[PATH_MAX
]="";
55 char file_citadel_rc
[PATH_MAX
]="";
56 char file_citadel_config
[PATH_MAX
]="";
57 char file_lmtp_socket
[PATH_MAX
]="";
58 char file_lmtp_unfiltered_socket
[PATH_MAX
]="";
59 char file_arcq
[PATH_MAX
]="";
60 char file_citadel_socket
[PATH_MAX
]="";
61 char file_mail_aliases
[PATH_MAX
]="";
62 char file_pid_file
[PATH_MAX
]="";
63 char file_pid_paniclog
[PATH_MAX
]="";
64 char file_crpt_file_key
[PATH_MAX
]="";
65 char file_crpt_file_csr
[PATH_MAX
]="";
66 char file_crpt_file_cer
[PATH_MAX
]="";
67 char file_chkpwd
[PATH_MAX
]="";
68 char file_base64
[PATH_MAX
]="";
69 char file_guesstimezone
[PATH_MAX
]="";
70 char file_funambol_msg
[PATH_MAX
] = "";
71 char file_dpsam_conf
[PATH_MAX
] = "";
72 char file_dspam_log
[PATH_MAX
] = "";
77 void StripSlashes(char *Dir
, int TrailingSlash
)
83 while (!IsEmptyStr(a
)) {
95 if ((TrailingSlash
) && (*(b
- 1) != '/')){
104 #define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\
105 snprintf(SUBDIR,sizeof SUBDIR, "%s%s%s%s%s%s%s", \
106 (home&!relh)?ctdl_home_directory:basedir, \
107 ((basedir!=ctdldir)&(home&!relh))?basedir:"/", \
108 ((basedir!=ctdldir)&(home&!relh))?"/":"", \
110 (relhome[0]!='\0')?"/":"",\
112 (dirbuffer[0]!='\0')?"/":"");
114 #define DBG_PRINT(A) if (dbg==1) fprintf (stderr,"%s : %s \n", #A, A)
117 void calc_dirs_n_files(int relh
, int home
, const char *relhome
, char *ctdldir
, int dbg
)
119 const char* basedir
= "";
120 char dirbuffer
[PATH_MAX
] = "";
123 * Ok, we keep our binaries either in the citadel base dir,
124 * or in /usr/sbin / /usr/bin
126 StripSlashes(ctdldir
, 1);
128 snprintf(ctdl_sbin_dir
, sizeof ctdl_sbin_dir
, "/usr/sbin/");
129 snprintf(ctdl_bin_dir
, sizeof ctdl_bin_dir
, "/usr/bin/");
131 snprintf(ctdl_sbin_dir
, sizeof ctdl_sbin_dir
, ctdldir
);
132 snprintf(ctdl_bin_dir
, sizeof ctdl_bin_dir
, ctdldir
);
134 StripSlashes(ctdl_sbin_dir
, 1);
135 StripSlashes(ctdl_bin_dir
, 1);
141 COMPUTE_DIRECTORY(ctdl_netcfg_dir
);
142 COMPUTE_DIRECTORY(ctdl_etc_dir
);
143 StripSlashes(ctdl_netcfg_dir
, 1);
144 StripSlashes(ctdl_etc_dir
, 1);
146 #ifndef HAVE_UTILBIN_DIR
151 COMPUTE_DIRECTORY(ctdl_utilbin_dir
);
152 StripSlashes(ctdl_utilbin_dir
, 1);
159 COMPUTE_DIRECTORY(ctdl_run_dir
);
160 StripSlashes(ctdl_run_dir
, 1);
162 #ifndef HAVE_STATICDATA_DIR
165 basedir
=STATICDATA_DIR
;
167 COMPUTE_DIRECTORY(ctdl_message_dir
);
168 StripSlashes(ctdl_message_dir
, 1);
170 #ifndef HAVE_HELP_DIR
175 COMPUTE_DIRECTORY(ctdl_hlp_dir
);
176 StripSlashes(ctdl_hlp_dir
, 1);
178 #ifndef HAVE_DATA_DIR
183 COMPUTE_DIRECTORY(ctdl_bio_dir
);
184 COMPUTE_DIRECTORY(ctdl_bb_dir
);
185 COMPUTE_DIRECTORY(ctdl_data_dir
);
186 COMPUTE_DIRECTORY(ctdl_dspam_dir
);
187 COMPUTE_DIRECTORY(ctdl_file_dir
);
188 COMPUTE_DIRECTORY(ctdl_image_dir
);
189 COMPUTE_DIRECTORY(ctdl_info_dir
);
190 COMPUTE_DIRECTORY(ctdl_usrpic_dir
);
191 COMPUTE_DIRECTORY(ctdl_bbsbase_dir
);
193 StripSlashes(ctdl_bio_dir
, 1);
194 StripSlashes(ctdl_bb_dir
, 1);
195 StripSlashes(ctdl_data_dir
, 1);
196 StripSlashes(ctdl_dspam_dir
, 1);
197 StripSlashes(ctdl_file_dir
, 1);
198 StripSlashes(ctdl_image_dir
, 1);
199 StripSlashes(ctdl_info_dir
, 1);
200 StripSlashes(ctdl_usrpic_dir
, 1);
201 StripSlashes(ctdl_bbsbase_dir
, 1);
203 #ifndef HAVE_SPOOL_DIR
208 COMPUTE_DIRECTORY(ctdl_spool_dir
);
209 COMPUTE_DIRECTORY(ctdl_netout_dir
);
210 COMPUTE_DIRECTORY(ctdl_netin_dir
);
212 StripSlashes(ctdl_spool_dir
, 1);
213 StripSlashes(ctdl_netout_dir
, 1);
214 StripSlashes(ctdl_netin_dir
, 1);
216 /* ok, now we know the dirs, calc some commonly used files */
220 "%srefcount_adjustments.dat",
222 StripSlashes(file_arcq
, 0);
223 snprintf(file_citadel_control
,
224 sizeof file_citadel_control
,
228 StripSlashes(file_citadel_control
, 0);
229 snprintf(file_citadel_config
,
230 sizeof file_citadel_config
,
233 StripSlashes(file_citadel_config
, 0);
234 snprintf(file_citadel_rc
,
235 sizeof file_citadel_rc
,
238 StripSlashes(file_citadel_rc
, 0);
239 snprintf(file_lmtp_socket
,
240 sizeof file_lmtp_socket
,
243 StripSlashes(file_lmtp_socket
, 0);
244 snprintf(file_lmtp_unfiltered_socket
,
245 sizeof file_lmtp_socket
,
246 "%slmtp-unfiltered.socket",
248 StripSlashes(file_lmtp_unfiltered_socket
, 0);
249 snprintf(file_citadel_socket
,
250 sizeof file_citadel_socket
,
253 StripSlashes(file_citadel_socket
, 0);
254 snprintf(file_pid_file
,
255 sizeof file_pid_file
,
258 StripSlashes(file_pid_file
, 0);
259 snprintf(file_pid_paniclog
,
260 sizeof file_pid_paniclog
,
262 ctdl_home_directory
);
263 StripSlashes(file_pid_paniclog
, 0);
264 snprintf(file_crpt_file_key
,
265 sizeof file_crpt_file_key
,
268 StripSlashes(file_crpt_file_key
, 0);
269 snprintf(file_crpt_file_csr
,
270 sizeof file_crpt_file_csr
,
273 StripSlashes(file_crpt_file_csr
, 0);
274 snprintf(file_crpt_file_cer
,
275 sizeof file_crpt_file_cer
,
278 StripSlashes(file_crpt_file_cer
, 0);
279 snprintf(file_chkpwd
,
283 StripSlashes(file_chkpwd
, 0);
284 snprintf(file_base64
,
288 StripSlashes(file_base64
, 0);
289 snprintf(file_guesstimezone
,
290 sizeof file_guesstimezone
,
291 "%sguesstimezone.sh",
294 snprintf(file_dpsam_conf
,
295 sizeof file_dpsam_conf
,
298 StripSlashes(file_dpsam_conf
, 0);
299 snprintf(file_dspam_log
,
300 sizeof file_dspam_log
,
302 ctdl_home_directory
);
303 StripSlashes(file_dspam_log
, 0);
305 * DIRTY HACK FOLLOWS! due to configs in the network dir in the
306 * legacy installations, we need to calculate ifdeffed here.
308 snprintf(file_mail_aliases
,
309 sizeof file_mail_aliases
,
317 StripSlashes(file_mail_aliases
, 0);
318 snprintf(file_funambol_msg
,
319 sizeof file_funambol_msg
,
320 "%sfunambol_newmail_soap.xml",
322 StripSlashes(file_funambol_msg
, 0);
324 DBG_PRINT(ctdl_bio_dir
);
325 DBG_PRINT(ctdl_bb_dir
);
326 DBG_PRINT(ctdl_data_dir
);
327 DBG_PRINT(ctdl_dspam_dir
);
328 DBG_PRINT(ctdl_file_dir
);
329 DBG_PRINT(ctdl_hlp_dir
);
330 DBG_PRINT(ctdl_image_dir
);
331 DBG_PRINT(ctdl_info_dir
);
332 DBG_PRINT(ctdl_key_dir
);
333 DBG_PRINT(ctdl_message_dir
);
334 DBG_PRINT(ctdl_usrpic_dir
);
335 DBG_PRINT(ctdl_etc_dir
);
336 DBG_PRINT(ctdl_run_dir
);
337 DBG_PRINT(ctdl_spool_dir
);
338 DBG_PRINT(ctdl_netout_dir
);
339 DBG_PRINT(ctdl_netin_dir
);
340 DBG_PRINT(ctdl_netcfg_dir
);
341 DBG_PRINT(ctdl_bbsbase_dir
);
342 DBG_PRINT(ctdl_sbin_dir
);
343 DBG_PRINT(ctdl_bin_dir
);
344 DBG_PRINT(ctdl_utilbin_dir
);
345 DBG_PRINT(file_citadel_control
);
346 DBG_PRINT(file_citadel_rc
);
347 DBG_PRINT(file_citadel_config
);
348 DBG_PRINT(file_lmtp_socket
);
349 DBG_PRINT(file_lmtp_unfiltered_socket
);
350 DBG_PRINT(file_arcq
);
351 DBG_PRINT(file_citadel_socket
);
352 DBG_PRINT(file_mail_aliases
);
353 DBG_PRINT(file_pid_file
);
354 DBG_PRINT(file_pid_paniclog
);
355 DBG_PRINT(file_crpt_file_key
);
356 DBG_PRINT(file_crpt_file_csr
);
357 DBG_PRINT(file_crpt_file_cer
);
358 DBG_PRINT(file_chkpwd
);
359 DBG_PRINT(file_base64
);
360 DBG_PRINT(file_guesstimezone
);
361 DBG_PRINT(file_funambol_msg
);
366 * Generate an associated file name for a room
368 void assoc_file_name(char *buf
, size_t n
,
369 struct ctdlroom
*qrbuf
, const char *prefix
)
371 snprintf(buf
, n
, "%s%ld", prefix
, qrbuf
->QRnumber
);