** DosFCheck - check file names for DOS consistency
** Distribute freely, it only encourages DOS compatibility!
/****************************************************************\
\****************************************************************/
printf ("The following files are not valid DOS file names:\n");
ENT
*rv
= (ENT
*)malloc (sizeof (ENT
));
fprintf (stderr
, "Unable to allocate memory for an ENT\n");
memset (rv
, 0, sizeof (ENT
));
fill_ent (ENT
*ent
, char *path
)
char *null
= path
+strlen (path
);
char *last_slash
= strrchr (path
, '/');
int dots_seen
, chars_seen
;
if (last_slash
+1 == null
)
last_slash
= strrchr (path
, '/');
if (null
-last_slash
< 13)
ent
->dos_name
= (char *)malloc (null
-last_slash
);
ent
->dos_name
= (char *)malloc (13);
ent
->full_name
= (char *)malloc (null
-last_slash
);
ent
->path
= (char *)malloc (last_slash
-first
+1);
strcpy (ent
->full_name
, last_slash
+1);
strncpy (ent
->path
, first
, last_slash
-first
);
ent
->path
[last_slash
-first
] = '\0';
printf ("%s - too many dots\n", path
);
printf ("%s - invalid character `%c'\n", path
, *cp
);
if ((*cp
<= ' ') || (*cp
>= 0x7f))
printf ("%s - invalid character `%c'\n", path
, *cp
);
compare_ent_dosname (ENT
**e1
, ENT
**e2
)
int r
= strcmp ((*e1
)->dos_name
, (*e2
)->dos_name
);
r
= strcmp ((*e1
)->path
, (*e2
)->path
);
r
= strcmp ((*e1
)->full_name
, (*e2
)->full_name
);
compare_ent_fullname (ENT
**e1
, ENT
**e2
)
int r
= strncmp ((*e1
)->full_name
, (*e2
)->full_name
, 14);
r
= strcmp ((*e1
)->path
, (*e2
)->path
);
r
= strcmp ((*e1
)->full_name
, (*e2
)->full_name
);
sprintf (buf
, "%s/%s", ent
->path
, ent
->full_name
);
/****************************************************************\
* List handling routines *
\****************************************************************/
handle_input (char *line
)
int ecount
, i
, first
, first_err
;
for (ecount
=0, ent
=eroot
; ent
; ent
=ent
->next
, ecount
++);
elist
= (ENT
**)malloc (sizeof (ENT
*) * ecount
);
for (ecount
=0, ent
=eroot
; ent
; ent
=ent
->next
, ecount
++)
qsort (elist
, ecount
, sizeof (ENT
*), compare_ent_dosname
);
for (i
=0; i
<ecount
-1; i
++)
if ((strcmp (elist
[i
]->dos_name
, elist
[i
+1]->dos_name
) == 0) &&
(strcmp (elist
[i
]->path
, elist
[i
+1]->path
) == 0))
printf ("The following resolve to the same DOS file names:\n");
printf ("%14s : %s\n", elist
[i
]->dos_name
, mpath (elist
[i
]));
printf ("\t\t %s\n", mpath (elist
[i
+1]));
qsort (elist
, ecount
, sizeof (ENT
*), compare_ent_fullname
);
for (i
=0; i
<ecount
-1; i
++)
if ((strncmp (elist
[i
]->full_name
, elist
[i
+1]->full_name
, 14) == 0) &&
(strcmp (elist
[i
]->path
, elist
[i
+1]->path
) == 0))
printf ("The following resolve to the same SysV file names:\n");
printf ("%.14s : %s\n", elist
[i
]->full_name
, mpath (elist
[i
]));
printf ("\t\t %s\n", mpath (elist
[i
+1]));
if ((strlen (elist
[i
]->full_name
) > 14) && !elist
[i
]->tagged
)
printf ("The following file names are too long for SysV:\n");
printf ("%.14s : %s\n", elist
[i
]->full_name
, mpath (elist
[i
]));
/****************************************************************\
\****************************************************************/
main (int argc
, char **argv
)
input
= fopen (argv
[1], "r");
fgets (line
, 500, input
);
while ((lp
!= line
) && (*lp
<= ' '))