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_shared_dir
[PATH_MAX
]="";
37 char ctdl_image_dir
[PATH_MAX
]="images";
38 char ctdl_info_dir
[PATH_MAX
]="info";
39 char ctdl_key_dir
[PATH_MAX
]=SSL_DIR
;
40 char ctdl_message_dir
[PATH_MAX
]="messages";
41 char ctdl_usrpic_dir
[PATH_MAX
]="userpics";
42 char ctdl_bbsbase_dir
[PATH_MAX
]="";
43 char ctdl_etc_dir
[PATH_MAX
]="";
44 char ctdl_autoetc_dir
[PATH_MAX
]="";
45 /* attention! this may be non volatile on some oses */
46 char ctdl_run_dir
[PATH_MAX
]="";
47 char ctdl_spool_dir
[PATH_MAX
]="network";
48 char ctdl_netout_dir
[PATH_MAX
]="network/spoolout";
49 char ctdl_netin_dir
[PATH_MAX
]="network/spoolin";
50 char ctdl_netcfg_dir
[PATH_MAX
]="netconfigs";
51 char ctdl_utilbin_dir
[PATH_MAX
]="";
52 char ctdl_sbin_dir
[PATH_MAX
]="";
53 char ctdl_bin_dir
[PATH_MAX
]="";
55 /* some of our files, that are needed in several places */
56 char file_citadel_control
[PATH_MAX
]="";
57 char file_citadel_rc
[PATH_MAX
]="";
58 char file_citadel_config
[PATH_MAX
]="";
59 char file_lmtp_socket
[PATH_MAX
]="";
60 char file_lmtp_unfiltered_socket
[PATH_MAX
]="";
61 char file_arcq
[PATH_MAX
]="";
62 char file_citadel_socket
[PATH_MAX
]="";
63 char file_mail_aliases
[PATH_MAX
]="";
64 char file_pid_file
[PATH_MAX
]="";
65 char file_pid_paniclog
[PATH_MAX
]="";
66 char file_crpt_file_key
[PATH_MAX
]="";
67 char file_crpt_file_csr
[PATH_MAX
]="";
68 char file_crpt_file_cer
[PATH_MAX
]="";
69 char file_chkpwd
[PATH_MAX
]="";
70 char file_base64
[PATH_MAX
]="";
71 char file_guesstimezone
[PATH_MAX
]="";
72 char file_funambol_msg
[PATH_MAX
] = "";
73 char file_dpsam_conf
[PATH_MAX
] = "";
74 char file_dspam_log
[PATH_MAX
] = "";
79 void StripSlashes(char *Dir
, int TrailingSlash
)
85 while (!IsEmptyStr(a
)) {
97 if ((TrailingSlash
) && (*(b
- 1) != '/')){
106 #define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\
107 snprintf(SUBDIR,sizeof SUBDIR, "%s%s%s%s%s%s%s", \
108 (home&!relh)?ctdl_home_directory:basedir, \
109 ((basedir!=ctdldir)&(home&!relh))?basedir:"/", \
110 ((basedir!=ctdldir)&(home&!relh))?"/":"", \
112 (relhome[0]!='\0')?"/":"",\
114 (dirbuffer[0]!='\0')?"/":"");
116 #define DBG_PRINT(A) if (dbg==1) fprintf (stderr,"%s : %s \n", #A, A)
119 void calc_dirs_n_files(int relh
, int home
, const char *relhome
, char *ctdldir
, int dbg
)
121 const char* basedir
= "";
122 char dirbuffer
[PATH_MAX
] = "";
125 * Ok, we keep our binaries either in the citadel base dir,
126 * or in /usr/sbin / /usr/bin
128 StripSlashes(ctdldir
, 1);
130 snprintf(ctdl_sbin_dir
, sizeof ctdl_sbin_dir
, "/usr/sbin/");
131 snprintf(ctdl_bin_dir
, sizeof ctdl_bin_dir
, "/usr/bin/");
133 snprintf(ctdl_sbin_dir
, sizeof ctdl_sbin_dir
, ctdldir
);
134 snprintf(ctdl_bin_dir
, sizeof ctdl_bin_dir
, ctdldir
);
136 StripSlashes(ctdl_sbin_dir
, 1);
137 StripSlashes(ctdl_bin_dir
, 1);
139 #ifndef HAVE_AUTO_ETC_DIR
142 basedir
=AUTO_ETC_DIR
;
144 COMPUTE_DIRECTORY(ctdl_autoetc_dir
);
145 StripSlashes(ctdl_autoetc_dir
, 1);
152 COMPUTE_DIRECTORY(ctdl_netcfg_dir
);
153 COMPUTE_DIRECTORY(ctdl_etc_dir
);
154 StripSlashes(ctdl_netcfg_dir
, 1);
155 StripSlashes(ctdl_etc_dir
, 1);
157 #ifndef HAVE_UTILBIN_DIR
162 COMPUTE_DIRECTORY(ctdl_utilbin_dir
);
163 StripSlashes(ctdl_utilbin_dir
, 1);
170 COMPUTE_DIRECTORY(ctdl_run_dir
);
171 StripSlashes(ctdl_run_dir
, 1);
173 #ifndef HAVE_STATICDATA_DIR
176 basedir
=STATICDATA_DIR
;
178 COMPUTE_DIRECTORY(ctdl_message_dir
);
179 StripSlashes(ctdl_message_dir
, 1);
181 #ifndef HAVE_HELP_DIR
186 COMPUTE_DIRECTORY(ctdl_hlp_dir
);
187 StripSlashes(ctdl_hlp_dir
, 1);
188 COMPUTE_DIRECTORY(ctdl_shared_dir
);
189 StripSlashes(ctdl_shared_dir
, 1);
191 #ifndef HAVE_DATA_DIR
196 COMPUTE_DIRECTORY(ctdl_bio_dir
);
197 COMPUTE_DIRECTORY(ctdl_bb_dir
);
198 COMPUTE_DIRECTORY(ctdl_data_dir
);
199 COMPUTE_DIRECTORY(ctdl_dspam_dir
);
200 COMPUTE_DIRECTORY(ctdl_file_dir
);
201 COMPUTE_DIRECTORY(ctdl_image_dir
);
202 COMPUTE_DIRECTORY(ctdl_info_dir
);
203 COMPUTE_DIRECTORY(ctdl_usrpic_dir
);
204 COMPUTE_DIRECTORY(ctdl_bbsbase_dir
);
206 StripSlashes(ctdl_bio_dir
, 1);
207 StripSlashes(ctdl_bb_dir
, 1);
208 StripSlashes(ctdl_data_dir
, 1);
209 StripSlashes(ctdl_dspam_dir
, 1);
210 StripSlashes(ctdl_file_dir
, 1);
211 StripSlashes(ctdl_image_dir
, 1);
212 StripSlashes(ctdl_info_dir
, 1);
213 StripSlashes(ctdl_usrpic_dir
, 1);
214 StripSlashes(ctdl_bbsbase_dir
, 1);
216 #ifndef HAVE_SPOOL_DIR
221 COMPUTE_DIRECTORY(ctdl_spool_dir
);
222 COMPUTE_DIRECTORY(ctdl_netout_dir
);
223 COMPUTE_DIRECTORY(ctdl_netin_dir
);
225 StripSlashes(ctdl_spool_dir
, 1);
226 StripSlashes(ctdl_netout_dir
, 1);
227 StripSlashes(ctdl_netin_dir
, 1);
229 /* ok, now we know the dirs, calc some commonly used files */
233 "%srefcount_adjustments.dat",
235 StripSlashes(file_arcq
, 0);
236 snprintf(file_citadel_control
,
237 sizeof file_citadel_control
,
241 StripSlashes(file_citadel_control
, 0);
242 snprintf(file_citadel_config
,
243 sizeof file_citadel_config
,
246 StripSlashes(file_citadel_config
, 0);
247 snprintf(file_citadel_rc
,
248 sizeof file_citadel_rc
,
251 StripSlashes(file_citadel_rc
, 0);
252 snprintf(file_lmtp_socket
,
253 sizeof file_lmtp_socket
,
256 StripSlashes(file_lmtp_socket
, 0);
257 snprintf(file_lmtp_unfiltered_socket
,
258 sizeof file_lmtp_socket
,
259 "%slmtp-unfiltered.socket",
261 StripSlashes(file_lmtp_unfiltered_socket
, 0);
262 snprintf(file_citadel_socket
,
263 sizeof file_citadel_socket
,
266 StripSlashes(file_citadel_socket
, 0);
267 snprintf(file_pid_file
,
268 sizeof file_pid_file
,
271 StripSlashes(file_pid_file
, 0);
272 snprintf(file_pid_paniclog
,
273 sizeof file_pid_paniclog
,
275 ctdl_home_directory
);
276 StripSlashes(file_pid_paniclog
, 0);
277 snprintf(file_crpt_file_key
,
278 sizeof file_crpt_file_key
,
281 StripSlashes(file_crpt_file_key
, 0);
282 snprintf(file_crpt_file_csr
,
283 sizeof file_crpt_file_csr
,
286 StripSlashes(file_crpt_file_csr
, 0);
287 snprintf(file_crpt_file_cer
,
288 sizeof file_crpt_file_cer
,
291 StripSlashes(file_crpt_file_cer
, 0);
292 snprintf(file_chkpwd
,
296 StripSlashes(file_chkpwd
, 0);
297 snprintf(file_base64
,
301 StripSlashes(file_base64
, 0);
302 snprintf(file_guesstimezone
,
303 sizeof file_guesstimezone
,
304 "%sguesstimezone.sh",
307 snprintf(file_dpsam_conf
,
308 sizeof file_dpsam_conf
,
311 StripSlashes(file_dpsam_conf
, 0);
312 snprintf(file_dspam_log
,
313 sizeof file_dspam_log
,
315 ctdl_home_directory
);
316 StripSlashes(file_dspam_log
, 0);
318 * DIRTY HACK FOLLOWS! due to configs in the network dir in the
319 * legacy installations, we need to calculate ifdeffed here.
321 snprintf(file_mail_aliases
,
322 sizeof file_mail_aliases
,
330 StripSlashes(file_mail_aliases
, 0);
331 snprintf(file_funambol_msg
,
332 sizeof file_funambol_msg
,
333 "%sfunambol_newmail_soap.xml",
335 StripSlashes(file_funambol_msg
, 0);
337 DBG_PRINT(ctdl_bio_dir
);
338 DBG_PRINT(ctdl_bb_dir
);
339 DBG_PRINT(ctdl_data_dir
);
340 DBG_PRINT(ctdl_dspam_dir
);
341 DBG_PRINT(ctdl_file_dir
);
342 DBG_PRINT(ctdl_hlp_dir
);
343 DBG_PRINT(ctdl_image_dir
);
344 DBG_PRINT(ctdl_info_dir
);
345 DBG_PRINT(ctdl_key_dir
);
346 DBG_PRINT(ctdl_message_dir
);
347 DBG_PRINT(ctdl_usrpic_dir
);
348 DBG_PRINT(ctdl_etc_dir
);
349 DBG_PRINT(ctdl_run_dir
);
350 DBG_PRINT(ctdl_spool_dir
);
351 DBG_PRINT(ctdl_netout_dir
);
352 DBG_PRINT(ctdl_netin_dir
);
353 DBG_PRINT(ctdl_netcfg_dir
);
354 DBG_PRINT(ctdl_bbsbase_dir
);
355 DBG_PRINT(ctdl_sbin_dir
);
356 DBG_PRINT(ctdl_bin_dir
);
357 DBG_PRINT(ctdl_utilbin_dir
);
358 DBG_PRINT(file_citadel_control
);
359 DBG_PRINT(file_citadel_rc
);
360 DBG_PRINT(file_citadel_config
);
361 DBG_PRINT(file_lmtp_socket
);
362 DBG_PRINT(file_lmtp_unfiltered_socket
);
363 DBG_PRINT(file_arcq
);
364 DBG_PRINT(file_citadel_socket
);
365 DBG_PRINT(file_mail_aliases
);
366 DBG_PRINT(file_pid_file
);
367 DBG_PRINT(file_pid_paniclog
);
368 DBG_PRINT(file_crpt_file_key
);
369 DBG_PRINT(file_crpt_file_csr
);
370 DBG_PRINT(file_crpt_file_cer
);
371 DBG_PRINT(file_chkpwd
);
372 DBG_PRINT(file_base64
);
373 DBG_PRINT(file_guesstimezone
);
374 DBG_PRINT(file_funambol_msg
);
379 * Generate an associated file name for a room
381 void assoc_file_name(char *buf
, size_t n
,
382 struct ctdlroom
*qrbuf
, const char *prefix
)
384 snprintf(buf
, n
, "%s%ld", prefix
, qrbuf
->QRnumber
);