summaryrefslogtreecommitdiff
path: root/dviware/dvi2qms/move_fonts.c
blob: b13198677e99fcd5cc0a08721195e59429976a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <sys/types.h>
#include <sys/dir.h>

main(argc,argv)
     int argc;
     char *argv[];
{
  DIR *dirstream;
  struct direct *dirrecord;
  char *dir,qfamily[128],s[MAXNAMLEN];
  int qpoint,qmag;

  if (argc != 2) exit(1);
  dir = argv[1];
  chdir(dir);
  if (dirstream = opendir(dir)) {
    while (dirrecord = readdir(dirstream)) {
      if (!strcmp(dirrecord->d_name+dirrecord->d_namlen-3,"pxl")) {
	qpoint = -1; qmag = -1;
	(void) sscanf(dirrecord->d_name,"%[^0123456789.]%d.%d",
		      qfamily,&qpoint,&qmag);
	mkdir(qfamily,0775);
	if (qpoint >= 0) {
	  sprintf(s,"%s%d",qfamily,qpoint);
	  mkdir(s,0775);
	  sprintf(s,"%s%d/%s",qfamily,qpoint,dirrecord->d_name);
	} else {
	  sprintf(s,"%s",qfamily);
	  mkdir(s,0775);
	  sprintf(s,"%s/%s",qfamily,dirrecord->d_name);
	}
	link(dirrecord->d_name,s);
      }
    }
    closedir(dirstream);
  }
}