3 Copyright 2000, 2015 Akira Kakuto.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, see <http://www.gnu.org/licenses/>.
18 Web2C 2010 (2010/08/22 --ak)
21 #include <kpathsea/kpathsea.h>
23 #include <kpathsea/dirent.h>
28 #define HDL "%% ls-R -- filename database for kpathsea; do not change this line.\n"
30 #define VARTEXFONTS "c:/var/tex/fonts/ls-R"
44 if((dp
= opendir(name
))) {
45 fprintf(ls_R
, "\n%s:\n", name
);
46 while((de
= readdir(dp
))) {
47 if(stricmp(de
->d_name
, ".") &&
48 stricmp(de
->d_name
, "..") &&
49 stricmp(de
->d_name
, ".bzr") &&
50 stricmp(de
->d_name
, ".git") &&
51 stricmp(de
->d_name
, ".hg") &&
52 stricmp(de
->d_name
, ".svn") &&
53 stricmp(de
->d_name
, "_bzr") &&
54 stricmp(de
->d_name
, "_git") &&
55 stricmp(de
->d_name
, "_hg") &&
56 stricmp(de
->d_name
, "_svn") &&
57 stricmp(de
->d_name
, "_darcs")) {
58 fprintf(ls_R
, "%s\n", de
->d_name
);
63 len
= (int)strlen(name
);
65 if(name
[len
-1] != '/') {
71 while((de
= readdir(dp
))) {
72 if(stricmp(de
->d_name
, ".") &&
73 stricmp(de
->d_name
, "..") &&
74 stricmp(de
->d_name
, ".bzr") &&
75 stricmp(de
->d_name
, ".git") &&
76 stricmp(de
->d_name
, ".hg") &&
77 stricmp(de
->d_name
, ".svn") &&
78 stricmp(de
->d_name
, "_bzr") &&
79 stricmp(de
->d_name
, "_git") &&
80 stricmp(de
->d_name
, "_hg") &&
81 stricmp(de
->d_name
, "_svn") &&
82 stricmp(de
->d_name
, "_darcs")) {
84 strcpy(buff
+ len
, de
->d_name
);
90 strcpy(buff
+ len
, de
->d_name
);
101 char first_name
[] = "./";
103 int main(int ac
, char **av
)
112 kpse_set_program_name(av
[0], NULL
);
113 progname
= kpse_program_name
;
115 if(ac
> 1 && (!strncmp(av
[1], "-v", 2) || !strncmp(av
[1], "--v", 3))) {
116 puts (kpathsea_version_string
);
117 puts ("mktexlsr: (C version 1.1 --ak 2002-2015)");
121 if(ac
> 1 && (!strncmp(av
[1], "-h", 2) || !strncmp(av
[1], "--h", 3))) {
122 printf("Usage: %s [--quiet|--silent] [DIRS ...]\n\n"
123 "Rebuild all necessary ls-R filename databases completely. If one or\n"
124 "more arguments DIRS are given, these are used as texmf directories to\n"
125 "build ls-R for. Else all directories in the search path for ls-R files\n"
126 "($TEXMFDBS) are used.", av
[0]);
131 if(!strncmp(av
[1], "-q", 2) || !strncmp(av
[1], "--q", 3) ||
132 !strncmp(av
[1], "-s", 2) || !strncmp(av
[1], "--s", 3)) {
141 pathbuff
= xmalloc(numtree
* sizeof(char *));
142 for(i
=0; i
< numtree
; i
++) {
143 pathbuff
[i
] = xstrdup(av
[i
+1]);
144 normalize (pathbuff
[i
]);
147 if (!(pathbuff
= mkpaths (&numtree
))) {
148 fprintf (stderr
, "Maybe you are not using ls-R.\n");
153 for(i
= 0; i
< numtree
; i
++) {
154 strcpy(ls_R_name
, pathbuff
[i
]);
155 len
= strlen(ls_R_name
);
156 if(ls_R_name
[len
-1] != '/') strcat(ls_R_name
, "/");
157 strcat(ls_R_name
, "ls-R");
159 ls_R
= fopen(ls_R_name
, "wb");
161 fprintf(stdout
, "Cannot open %s to write.\n", ls_R_name
);
162 if(!stricmp(ls_R_name
, VARTEXFONTS
))
163 fprintf(stdout
, " (Don't mind this message.)\n");
167 cdrive
= _getdrive();
169 if(ls_R_name
[1] == ':') {
170 tdrive
= tolower(ls_R_name
[0]) - 'a' + 1;
176 fprintf(stdout
, "%s: Updating %s...\n", progname
, ls_R_name
);
182 fprintf(stdout
, "%s: Updated %s.\n", progname
, ls_R_name
);
187 fprintf(stdout
, "%s: Done.\n", progname
);
189 for(i
= 0; i
< numtree
; i
++) {