File:
[local] /
rpl /
rplsignal /
chemin.c
Revision
1.1:
download - view:
text,
annotated -
select for diffs -
revision graph
Tue May 22 07:52:24 2012 UTC (12 years, 11 months ago) by
bertrand
Branches:
MAIN
CVS tags:
rpl-4_1_9,
rpl-4_1_35,
rpl-4_1_34,
rpl-4_1_33,
rpl-4_1_32,
rpl-4_1_31,
rpl-4_1_30,
rpl-4_1_29,
rpl-4_1_28,
rpl-4_1_27,
rpl-4_1_26,
rpl-4_1_25,
rpl-4_1_24,
rpl-4_1_23,
rpl-4_1_22,
rpl-4_1_21,
rpl-4_1_20,
rpl-4_1_19,
rpl-4_1_18,
rpl-4_1_17,
rpl-4_1_16,
rpl-4_1_15,
rpl-4_1_14,
rpl-4_1_13,
rpl-4_1_12,
rpl-4_1_11,
rpl-4_1_10,
HEAD
Ajout de l'utilitaire rplsignal.
1: unsigned char *
2: recherche_chemin_fichiers_temporaires()
3: {
4: FILE *fichier;
5:
6: unsigned char *candidat;
7: unsigned char *chemin;
8: unsigned char *chemins[] = { "$RPL_TMP_PATH",
9: "/tmp", "/var/tmp", NULL };
10: unsigned char fichier_test[] = "/RPL-SIGNAL-TEST";
11: unsigned char *nom_candidat;
12:
13: unsigned long int i;
14:
15: i = 0;
16: chemin = NULL;
17:
18: while(chemin == NULL)
19: {
20: if (chemins[i][0] == '$')
21: {
22: candidat = getenv(chemins[i] + 1);
23:
24: if (candidat != NULL)
25: {
26: if ((nom_candidat = malloc((strlen(candidat) +
27: strlen(fichier_test) + 1) * sizeof(unsigned char)))
28: == NULL)
29: {
30: return(NULL);
31: }
32:
33: sprintf(nom_candidat, "%s%s", candidat, fichier_test);
34:
35: if ((fichier = fopen(nom_candidat, "w+")) != NULL)
36: {
37: fclose(fichier);
38: unlink(nom_candidat);
39: free(nom_candidat);
40:
41: if ((chemin = malloc((strlen(candidat) + 1)
42: * sizeof(unsigned char))) != NULL)
43: {
44: strcpy(chemin, candidat);
45: }
46: else
47: {
48: return(NULL);
49: }
50: }
51: else
52: {
53: free(nom_candidat);
54: }
55: }
56: }
57: else
58: {
59: if ((nom_candidat = malloc((strlen(candidat) +
60: strlen(fichier_test) + 1) * sizeof(unsigned char)))
61: == NULL)
62: {
63: return(NULL);
64: }
65:
66: sprintf(nom_candidat, "%s%s", candidat, fichier_test);
67:
68: if ((fichier = fopen(nom_candidat, "w+")) != NULL)
69: {
70: fclose(fichier);
71: unlink(nom_candidat);
72: free(nom_candidat);
73:
74: if ((chemin = malloc((strlen(candidat) + 1)
75: * sizeof(unsigned char))) != NULL)
76: {
77: strcpy(chemin, candidat);
78: }
79: else
80: {
81: return(NULL);
82: }
83: }
84: else
85: {
86: free(nom_candidat);
87: }
88: }
89:
90: i++
91: }
92:
93: return(chemin);
94: }
95:
96: // vim: ts=4
97:
CVSweb interface <joel.bertrand@systella.fr>