2 * $RCSId: xc/lib/fontconfig/src/fccache.c,v 1.12 2002/08/22 07:36:44 keithp Exp $
4 * Copyright © 2000 Keith Packard
5 * Copyright © 2005 Patrick Lam
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Keith Packard not be used in
12 * advertising or publicity pertaining to distribution of the software without
13 * specific, written prior permission. Keith Packard makes no
14 * representations about the suitability of this software for any purpose. It
15 * is provided "as is" without express or implied warranty.
17 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23 * PERFORMANCE OF THIS SOFTWARE.
30 #include <sys/utsname.h>
31 #include <sys/types.h>
36 #define ENDIAN_TEST 0x12345678
37 #define MACHINE_SIGNATURE_SIZE 9 + 5*20 + 1
40 FcDirCacheOpen (const FcChar8
* dir
);
43 FcDirCacheHashName (char * cache_file
, int collisions
);
46 FcCacheSkipToArch (int fd
, const char * arch
);
49 FcCacheCopyOld (int fd
, int fd_orig
, off_t start
);
52 FcDirCacheProduce (FcFontSet
*set
, FcCache
* metadata
);
55 FcDirCacheConsume (int fd
, const char * dir
, FcFontSet
*set
, FcConfig
*config
);
58 FcCacheNextOffset(off_t w
);
61 FcCacheMachineSignature (void);
64 FcCacheHaveBank (int bank
);
67 FcCacheAddBankDir (int bank
, const char * dir
);
75 static void MD5Init(struct MD5Context
*ctx
);
76 static void MD5Update(struct MD5Context
*ctx
, unsigned char *buf
, unsigned len
);
77 static void MD5Final(unsigned char digest
[16], struct MD5Context
*ctx
);
78 static void MD5Transform(FcChar32 buf
[4], FcChar32 in
[16]);
80 #define FC_DBG_CACHE_REF 1024
83 FcCacheReadString (int fd
, char *dest
, int len
)
91 size
= read (fd
, dest
, len
-1);
98 lseek (fd
, slen
- size
+ 1, SEEK_CUR
);
99 return slen
< len
? dest
: 0;
106 FcCacheSkipString (int fd
)
112 while ( (size
= read (fd
, buf
, sizeof (buf
)-1)) > 0)
118 lseek (fd
, slen
- size
+ 1, SEEK_CUR
);
125 FcCacheWriteString (int fd
, const char *chars
)
127 if (write (fd
, chars
, strlen(chars
)+1) != strlen(chars
)+1)
133 FcGlobalCacheDirDestroy (FcGlobalCacheDir
*d
)
135 FcStrSetDestroy (d
->subdirs
);
136 FcMemFree (FC_MEM_STRING
, strlen (d
->name
)+1);
138 FcMemFree (FC_MEM_CACHE
, sizeof (FcGlobalCacheDir
));
143 FcGlobalCacheCreate (void)
145 FcGlobalCache
*cache
;
147 cache
= malloc (sizeof (FcGlobalCache
));
150 FcMemAlloc (FC_MEM_CACHE
, sizeof (FcGlobalCache
));
152 cache
->updated
= FcFalse
;
158 FcGlobalCacheDestroy (FcGlobalCache
*cache
)
160 FcGlobalCacheDir
*d
, *next
;
162 for (d
= cache
->dirs
; d
; d
= next
)
165 FcGlobalCacheDirDestroy (d
);
167 FcMemFree (FC_MEM_CACHE
, sizeof (FcGlobalCache
));
172 FcGlobalCacheLoad (FcGlobalCache
*cache
,
174 const FcChar8
*cache_file
,
177 char name_buf
[FC_MAX_FILE_LEN
];
178 FcGlobalCacheDir
*d
, *next
;
179 FcFileTime config_time
= FcConfigModifiedTime (config
);
180 char * current_arch_machine_name
;
181 char candidate_arch_machine_name
[MACHINE_SIGNATURE_SIZE
+ 9];
182 off_t current_arch_start
;
184 struct stat cache_stat
, dir_stat
;
185 char subdirName
[FC_MAX_FILE_LEN
+ 1 + 12 + 1];
187 if (stat ((char *) cache_file
, &cache_stat
) < 0)
190 cache
->fd
= open ((char *) cache_file
, O_RDONLY
);
194 cache
->updated
= FcFalse
;
196 if (!FcCacheReadString (cache
->fd
, name_buf
, sizeof (name_buf
)))
197 goto bail_and_destroy
;
198 if (strcmp (name_buf
, FC_GLOBAL_MAGIC_COOKIE
) != 0)
199 goto bail_and_destroy
;
201 current_arch_machine_name
= FcCacheMachineSignature ();
202 current_arch_start
= FcCacheSkipToArch(cache
->fd
,
203 current_arch_machine_name
);
204 if (current_arch_start
< 0)
205 goto bail_and_destroy
;
207 lseek (cache
->fd
, current_arch_start
, SEEK_SET
);
208 if (!FcCacheReadString (cache
->fd
, candidate_arch_machine_name
,
209 sizeof (candidate_arch_machine_name
)))
210 goto bail_and_destroy
;
211 if (strlen(candidate_arch_machine_name
) == 0)
212 goto bail_and_destroy
;
218 if (!FcCacheReadString (cache
->fd
, name_buf
, sizeof (name_buf
)) ||
222 /* Directory must be older than the global cache file; also
223 cache must be newer than the config file. */
224 if (stat ((char *) name_buf
, &dir_stat
) < 0 ||
225 dir_stat
.st_mtime
> cache_stat
.st_mtime
||
226 (config_time
.set
&& cache_stat
.st_mtime
< config_time
.time
))
231 FcStrSetAdd (staleDirs
, FcStrCopy ((FcChar8
*)name_buf
));
234 while (FcCacheReadString (cache
->fd
, subdirName
,
235 sizeof (subdirName
)) &&
239 if (read (cache
->fd
, &md
, sizeof (FcCache
)) != sizeof(FcCache
))
241 perror ("read metadata");
244 off
= FcCacheNextOffset (lseek(cache
->fd
, 0, SEEK_CUR
)) + md
.count
;
245 if (lseek (cache
->fd
, off
, SEEK_SET
) != off
)
253 d
= malloc (sizeof (FcGlobalCacheDir
));
257 d
->next
= cache
->dirs
;
260 d
->name
= (char *)FcStrCopy ((FcChar8
*)name_buf
);
262 d
->state
= FcGCDirFileRead
;
264 d
->subdirs
= FcStrSetCreate();
267 if (!FcCacheReadString (cache
->fd
, subdirName
,
268 sizeof (subdirName
)) ||
269 !strlen (subdirName
))
271 FcStrSetAdd (d
->subdirs
, (FcChar8
*)subdirName
);
274 d
->offset
= lseek (cache
->fd
, 0, SEEK_CUR
);
275 if (read (cache
->fd
, &d
->metadata
, sizeof (FcCache
)) != sizeof (FcCache
))
277 targ
= FcCacheNextOffset (lseek(cache
->fd
, 0, SEEK_CUR
)) + d
->metadata
.count
;
278 if (lseek (cache
->fd
, targ
, SEEK_SET
) != targ
)
284 for (d
= cache
->dirs
; d
; d
= next
)
299 if (stat ((char *) cache_file
, &cache_stat
) == 0)
300 unlink ((char *)cache_file
);
307 FcGlobalCacheReadDir (FcFontSet
*set
, FcStrSet
*dirs
, FcGlobalCache
* cache
, const char *dir
, FcConfig
*config
)
315 if (!(dir
= (char *)FcConfigNormalizeFontDir (config
, (FcChar8
*)dir
)))
316 return FcFalse
; /* non-existing directory */
318 for (d
= cache
->dirs
; d
; d
= d
->next
)
320 if (strcmp (d
->name
, dir
) == 0)
322 if (d
->state
== FcGCDirDisabled
)
325 if (d
->state
== FcGCDirFileRead
)
327 lseek (cache
->fd
, d
->offset
, SEEK_SET
);
328 if (!FcDirCacheConsume (cache
->fd
, d
->name
, set
, config
))
331 for (i
= 0; i
< d
->subdirs
->num
; i
++)
332 FcStrSetAdd (dirs
, (FcChar8
*)d
->subdirs
->strs
[i
]);
334 d
->state
= FcGCDirConsumed
;
343 static FcGlobalCacheDir
*
344 FcGlobalCacheDirFind (FcGlobalCache
*cache
, const char *name
)
346 FcGlobalCacheDir
* d
;
351 for (d
= cache
->dirs
; d
; d
= d
->next
)
352 if (strcmp((const char *)d
->name
, (const char *)name
) == 0)
359 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
361 const char *orig_name
,
369 name
= (char *)FcConfigNormalizeFontDir (config
, (FcChar8
*)orig_name
);
372 fprintf(stderr
, "Invalid directory name %s\n", orig_name
);
376 d
= FcGlobalCacheDirFind (cache
, name
);
380 d
= malloc (sizeof (FcGlobalCacheDir
));
383 d
->next
= cache
->dirs
;
386 /* free old resources */
387 FcStrFree ((FcChar8
*)d
->name
);
389 FcStrSetDestroy (d
->subdirs
);
392 cache
->updated
= FcTrue
;
394 d
->name
= (char *)FcStrCopy ((FcChar8
*)name
);
395 d
->ent
= FcDirCacheProduce (set
, &d
->metadata
);
397 d
->subdirs
= FcStrSetCreate();
398 d
->state
= FcGCDirUpdated
;
399 for (i
= 0; i
< dirs
->num
; i
++)
400 FcStrSetAdd (d
->subdirs
, dirs
->strs
[i
]);
405 FcGlobalCacheSave (FcGlobalCache
*cache
,
406 const FcChar8
*cache_file
,
410 FcGlobalCacheDir
*dir
;
412 off_t current_arch_start
= 0, truncate_to
;
413 char * current_arch_machine_name
, * header
;
418 #if defined (HAVE_GETUID) && defined (HAVE_GETEUID)
419 /* Set-UID programs can't safely update the cache */
420 if (getuid () != geteuid ())
424 atomic
= FcAtomicCreate (cache_file
);
428 if (!FcAtomicLock (atomic
))
430 fd
= open ((char *) FcAtomicNewFile(atomic
), O_RDWR
| O_CREAT
,
434 FcCacheWriteString (fd
, FC_GLOBAL_MAGIC_COOKIE
);
436 fd_orig
= open ((char *) FcAtomicOrigFile(atomic
), O_RDONLY
);
438 current_arch_machine_name
= FcCacheMachineSignature ();
440 current_arch_start
= 0;
442 current_arch_start
= FcCacheSkipToArch (fd_orig
,
443 current_arch_machine_name
);
445 if (current_arch_start
< 0)
447 off_t i
= lseek(fd_orig
, 0, SEEK_END
);
448 if (i
< strlen (FC_GLOBAL_MAGIC_COOKIE
)+1)
449 i
= strlen (FC_GLOBAL_MAGIC_COOKIE
)+1;
450 current_arch_start
= FcCacheNextOffset (i
);
453 if (!FcCacheCopyOld(fd
, fd_orig
, current_arch_start
))
456 current_arch_start
= lseek(fd
, 0, SEEK_CUR
);
457 if (ftruncate (fd
, current_arch_start
) == -1)
460 header
= malloc (10 + strlen (current_arch_machine_name
));
464 truncate_to
= current_arch_start
+ strlen(current_arch_machine_name
) + 11;
465 for (dir
= cache
->dirs
; dir
; dir
= dir
->next
)
467 if (dir
->state
== FcGCDirDisabled
)
469 truncate_to
+= strlen(dir
->name
) + 1;
470 truncate_to
+= sizeof (FcCache
);
471 truncate_to
= FcCacheNextOffset (truncate_to
);
472 truncate_to
+= dir
->metadata
.count
;
474 for (i
= 0; i
< dir
->subdirs
->size
; i
++)
475 truncate_to
+= strlen((char *)dir
->subdirs
->strs
[i
]) + 1;
478 truncate_to
-= current_arch_start
;
480 sprintf (header
, "%8x ", (int)truncate_to
);
481 strcat (header
, current_arch_machine_name
);
482 if (!FcCacheWriteString (fd
, header
))
485 for (dir
= cache
->dirs
; dir
; dir
= dir
->next
)
490 if (!dir
->name
|| dir
->state
== FcGCDirDisabled
)
492 d
= (const char *)FcConfigNormalizeFontDir (config
, (const FcChar8
*)dir
->name
);
496 if (dir
->metadata
.count
&& !dir
->ent
)
498 if (dir
->state
== FcGCDirUpdated
|| fd_orig
< 0)
500 fprintf(stderr
, "Invalid metadata entry for %s, skipping...\n", d
);
503 /* copy the old content */
504 dir
->ent
= malloc (dir
->metadata
.count
);
507 perror("malloc error");
510 off
= FcCacheNextOffset (dir
->offset
+ sizeof(FcCache
));
511 if (lseek (fd_orig
, off
, SEEK_SET
) != off
)
517 if (read (fd_orig
, dir
->ent
, dir
->metadata
.count
)
518 != dir
->metadata
.count
)
526 FcCacheWriteString (fd
, d
);
528 for (i
= 0; i
< dir
->subdirs
->size
; i
++)
529 FcCacheWriteString (fd
, (char *)dir
->subdirs
->strs
[i
]);
530 FcCacheWriteString (fd
, "");
532 if (write (fd
, &dir
->metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
534 perror ("write metadata");
538 off
= FcCacheNextOffset (lseek(fd
, 0, SEEK_CUR
));
539 if (lseek (fd
, off
, SEEK_SET
) != off
)
545 if (dir
->metadata
.count
)
547 if (write (fd
, dir
->ent
, dir
->metadata
.count
) != dir
->metadata
.count
)
549 perror ("write dirent");
556 FcCacheWriteString (fd
, "");
558 if (close (fd
) == -1)
564 if (!FcAtomicReplaceOrig (atomic
))
567 FcAtomicUnlock (atomic
);
568 FcAtomicDestroy (atomic
);
570 cache
->updated
= FcFalse
;
581 FcAtomicDeleteNew (atomic
);
583 FcAtomicUnlock (atomic
);
585 FcAtomicDestroy (atomic
);
590 * Find the next presumably-mmapable offset after the supplied file
594 FcCacheNextOffset(off_t w
)
596 static long pagesize
= -1;
598 pagesize
= sysconf(_SC_PAGESIZE
);
599 if (w
% pagesize
== 0)
602 return ((w
/ pagesize
)+1)*pagesize
;
605 /* return the address of the segment for the provided arch,
606 * or -1 if arch not found */
608 FcCacheSkipToArch (int fd
, const char * arch
)
610 char candidate_arch_machine_name_count
[MACHINE_SIGNATURE_SIZE
+ 9];
611 char * candidate_arch
;
612 off_t current_arch_start
= 0;
614 lseek (fd
, 0, SEEK_SET
);
615 FcCacheSkipString (fd
);
616 current_arch_start
= lseek (fd
, 0, SEEK_CUR
);
618 /* skip arches that are not the current arch */
623 if (lseek (fd
, current_arch_start
, SEEK_SET
) != current_arch_start
)
626 if (FcCacheReadString (fd
, candidate_arch_machine_name_count
,
627 sizeof (candidate_arch_machine_name_count
)) == 0)
629 if (!strlen(candidate_arch_machine_name_count
))
631 bs
= strtol(candidate_arch_machine_name_count
, &candidate_arch
, 16);
633 // count = 0 should probably be distinguished from the !bs condition
634 if (!bs
|| bs
< strlen (candidate_arch_machine_name_count
))
637 candidate_arch
++; /* skip leading space */
639 if (strcmp (candidate_arch
, arch
)==0)
640 return current_arch_start
;
641 current_arch_start
+= bs
;
647 /* Cuts out the segment at the file pointer (moves everything else
648 * down to cover it), and leaves the file pointer at the end of the
651 FcCacheCopyOld (int fd
, int fd_orig
, off_t start
)
653 char * buf
= malloc (8192);
654 char candidate_arch_machine_name
[MACHINE_SIGNATURE_SIZE
+ 9];
656 int c
, bytes_skipped
;
663 lseek (fd
, 0, SEEK_SET
); lseek (fd_orig
, 0, SEEK_SET
);
670 if ((c
= read (fd_orig
, buf
, b
)) <= 0)
672 if (write (fd
, buf
, c
) < 0)
679 lseek (fd
, start
, SEEK_SET
);
680 if (FcCacheReadString (fd
, candidate_arch_machine_name
,
681 sizeof (candidate_arch_machine_name
)) == 0)
683 if (!strlen(candidate_arch_machine_name
))
686 bs
= strtol(candidate_arch_machine_name
, 0, 16);
693 lseek (fd
, start
+bs
+bytes_skipped
, SEEK_SET
);
694 if ((c
= read (fd
, buf
, 8192)) <= 0)
696 lseek (fd
, start
+bytes_skipped
, SEEK_SET
);
697 if (write (fd
, buf
, c
) < 0)
702 lseek (fd
, start
+bytes_skipped
, SEEK_SET
);
713 /* Does not check that the cache has the appropriate arch section. */
714 /* Also, this can be fooled if the original location has a stale
715 * cache, and the hashed location has an up-to-date cache. Oh well,
716 * sucks to be you in that case! */
718 FcDirCacheValid (const FcChar8
*dir
)
720 struct stat file_stat
, dir_stat
;
723 if (stat ((char *) dir
, &dir_stat
) < 0)
726 fd
= FcDirCacheOpen (dir
);
730 if (fstat (fd
, &file_stat
) < 0)
736 * If the directory has been modified more recently than
737 * the cache file, the cache is not valid
739 if (dir_stat
.st_mtime
> file_stat
.st_mtime
)
749 /* Assumes that the cache file in 'dir' exists.
750 * Checks that the cache has the appropriate arch section. */
752 FcDirCacheHasCurrentArch (const FcChar8
*dir
)
755 off_t current_arch_start
;
756 char *current_arch_machine_name
;
758 fd
= FcDirCacheOpen (dir
);
762 current_arch_machine_name
= FcCacheMachineSignature();
763 current_arch_start
= FcCacheSkipToArch(fd
, current_arch_machine_name
);
766 if (current_arch_start
< 0)
776 FcDirCacheUnlink (const FcChar8
*dir
, FcConfig
*config
)
779 char *cache_hashed
= 0;
781 struct stat cache_stat
;
782 char name_buf
[FC_MAX_FILE_LEN
];
784 dir
= FcConfigNormalizeFontDir (config
, dir
);
785 cache_file
= (char *)FcStrPlus (dir
, (FcChar8
*) "/" FC_DIR_CACHE_FILE
);
789 /* First remove normal cache file. */
790 if (stat ((char *) cache_file
, &cache_stat
) == 0 &&
791 unlink ((char *)cache_file
) != 0)
794 /* Next remove any applicable hashed files. */
795 fd
= -1; collisions
= 0;
799 FcStrFree ((FcChar8
*)cache_hashed
);
801 cache_hashed
= FcDirCacheHashName (cache_file
, collisions
++);
807 fd
= open(cache_hashed
, O_RDONLY
);
810 FcStrFree ((FcChar8
*)cache_file
);
814 if (!FcCacheReadString (fd
, name_buf
, sizeof (name_buf
)) || !strlen(name_buf
))
816 FcStrFree ((FcChar8
*)cache_hashed
);
819 } while (strcmp (name_buf
, cache_file
) != 0);
823 if (stat ((char *) cache_hashed
, &cache_stat
) == 0 &&
824 unlink ((char *)cache_hashed
) != 0)
826 FcStrFree ((FcChar8
*)cache_hashed
);
830 FcStrFree ((FcChar8
*)cache_file
);
831 FcStrFree ((FcChar8
*)cache_hashed
);
835 FcStrFree ((FcChar8
*)cache_file
);
840 FcCacheReadDirs (FcConfig
* config
, FcGlobalCache
* cache
,
841 FcStrList
*list
, FcFontSet
* set
, FcStrSet
*processed_dirs
)
852 * Read in the results from 'list'.
854 while ((dir
= FcStrListNext (list
)))
856 if (!FcConfigAcceptFilename (config
, dir
))
859 /* Skip this directory if already updated
860 * to avoid the looped directories via symlinks
862 name
= FcConfigNormalizeFontDir (config
, dir
);
865 if (FcStrSetMember (processed_dirs
, dir
))
867 FcStrSetAdd (processed_dirs
, dir
);
870 subdirs
= FcStrSetCreate ();
873 fprintf (stderr
, "Can't create directory set\n");
878 if (access ((char *) dir
, X_OK
) < 0)
886 fprintf (stderr
, "\"%s\": ", dir
);
890 FcStrSetDestroy (subdirs
);
893 if (stat ((char *) dir
, &statb
) == -1)
895 fprintf (stderr
, "\"%s\": ", dir
);
897 FcStrSetDestroy (subdirs
);
901 if (!S_ISDIR (statb
.st_mode
))
903 fprintf (stderr
, "\"%s\": not a directory, skipping\n", dir
);
904 FcStrSetDestroy (subdirs
);
907 if (FcDirCacheValid (dir
) && FcDirCacheRead (set
, subdirs
, dir
, config
))
909 /* if an old entry is found in the global cache, disable it */
910 if ((d
= FcGlobalCacheDirFind (cache
, (const char *)name
)) != NULL
)
912 d
->state
= FcGCDirDisabled
;
913 /* save the updated config later without this entry */
914 cache
->updated
= FcTrue
;
919 if (FcDebug () & FC_DBG_FONTSET
)
920 printf ("cache scan dir %s\n", dir
);
922 FcDirScanConfig (set
, subdirs
, cache
,
923 config
->blanks
, dir
, FcFalse
, config
);
925 sublist
= FcStrListCreate (subdirs
);
926 FcStrSetDestroy (subdirs
);
929 fprintf (stderr
, "Can't create subdir list in \"%s\"\n", dir
);
933 ret
+= FcCacheReadDirs (config
, cache
, sublist
, set
, processed_dirs
);
935 FcStrListDone (list
);
940 FcCacheRead (FcConfig
*config
, FcGlobalCache
* cache
)
942 FcFontSet
*s
= FcFontSetCreate();
943 FcStrSet
*processed_dirs
;
948 processed_dirs
= FcStrSetCreate();
952 if (FcCacheReadDirs (config
, cache
, FcConfigGetConfigDirs (config
), s
, processed_dirs
))
955 FcStrSetDestroy (processed_dirs
);
959 FcStrSetDestroy (processed_dirs
);
961 FcFontSetDestroy (s
);
965 static const char bin2hex
[] = { '0', '1', '2', '3',
968 'c', 'd', 'e', 'f' };
971 FcDirCacheHashName (char * cache_file
, int collisions
)
973 unsigned char hash
[16], hex_hash
[33];
975 unsigned char uscore
= '_';
978 struct MD5Context ctx
;
981 MD5Update (&ctx
, (unsigned char *)cache_file
, strlen (cache_file
));
983 for (i
= 0; i
< collisions
; i
++)
984 MD5Update (&ctx
, &uscore
, 1);
986 MD5Final (hash
, &ctx
);
988 for (cnt
= 0; cnt
< 16; ++cnt
)
990 hex_hash
[2*cnt
] = bin2hex
[hash
[cnt
] >> 4];
991 hex_hash
[2*cnt
+1] = bin2hex
[hash
[cnt
] & 0xf];
995 tmp
= FcStrPlus ((FcChar8
*)hex_hash
, (FcChar8
*)FC_CACHE_SUFFIX
);
999 cache_hashed
= (char *)FcStrPlus ((FcChar8
*)PKGCACHEDIR
"/", tmp
);
1002 return cache_hashed
;
1005 /* Opens the hashed name for cache_file.
1006 * This would fail in the unlikely event of a collision and subsequent
1007 * removal of the file which originally caused the collision. */
1009 FcDirCacheOpen (const FcChar8
*dir
)
1012 int fd
= -1, collisions
= 0;
1013 char *cache_file
, *cache_hashed
;
1014 char name_buf
[FC_MAX_FILE_LEN
];
1015 struct stat dir_stat
;
1017 cache_file
= (char *)FcStrPlus (dir
, (FcChar8
*) "/" FC_DIR_CACHE_FILE
);
1021 fd
= open(cache_file
, O_RDONLY
);
1025 if (stat ((char *)dir
, &dir_stat
) == -1)
1032 FcChar8
* name_buf_dir
;
1034 cache_hashed
= FcDirCacheHashName (cache_file
, collisions
++);
1037 FcStrFree ((FcChar8
*)cache_file
);
1043 fd
= open(cache_hashed
, O_RDONLY
);
1044 FcStrFree ((FcChar8
*)cache_hashed
);
1048 FcStrFree ((FcChar8
*)cache_file
);
1051 if (!FcCacheReadString (fd
, name_buf
, sizeof (name_buf
)) || !strlen(name_buf
))
1054 name_buf_dir
= FcStrDirname ((FcChar8
*)name_buf
);
1055 if (stat ((char *)name_buf_dir
, &c
) == -1)
1057 FcStrFree (name_buf_dir
);
1060 FcStrFree (name_buf_dir
);
1061 found
= (c
.st_ino
== dir_stat
.st_ino
) && (c
.st_dev
== dir_stat
.st_dev
);
1063 FcStrFree ((FcChar8
*)cache_file
);
1067 FcStrFree ((FcChar8
*)cache_file
);
1072 /* read serialized state from the cache file */
1074 FcDirCacheRead (FcFontSet
* set
, FcStrSet
* dirs
, const FcChar8
*dir
, FcConfig
*config
)
1077 char *current_arch_machine_name
;
1078 char candidate_arch_machine_name
[9+MACHINE_SIGNATURE_SIZE
];
1079 off_t current_arch_start
= 0;
1080 char subdirName
[FC_MAX_FILE_LEN
+ 1 + 12 + 1];
1082 fd
= FcDirCacheOpen (dir
);
1086 current_arch_machine_name
= FcCacheMachineSignature();
1087 current_arch_start
= FcCacheSkipToArch(fd
,
1088 current_arch_machine_name
);
1089 if (current_arch_start
< 0)
1092 lseek (fd
, current_arch_start
, SEEK_SET
);
1093 if (FcCacheReadString (fd
, candidate_arch_machine_name
,
1094 sizeof (candidate_arch_machine_name
)) == 0)
1097 while (FcCacheReadString (fd
, subdirName
, sizeof (subdirName
)) && strlen (subdirName
) > 0)
1098 FcStrSetAdd (dirs
, (FcChar8
*)subdirName
);
1100 if (!FcDirCacheConsume (fd
, (const char *)dir
, set
, config
))
1113 FcDirCacheConsume (int fd
, const char * dir
, FcFontSet
*set
, FcConfig
*config
)
1116 void * current_dir_block
;
1119 if (read(fd
, &metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
1121 if (metadata
.magic
!= FC_CACHE_MAGIC
)
1124 if (!metadata
.count
)
1126 pos
= FcCacheNextOffset (lseek(fd
, 0, SEEK_CUR
));
1127 lseek (fd
, pos
, SEEK_SET
);
1129 FcConfigAddFontDir (config
, (FcChar8
*)dir
);
1133 pos
= FcCacheNextOffset (lseek(fd
, 0, SEEK_CUR
));
1134 current_dir_block
= mmap (0, metadata
.count
,
1135 PROT_READ
, MAP_SHARED
, fd
, pos
);
1136 lseek (fd
, pos
+metadata
.count
, SEEK_SET
);
1137 if (current_dir_block
== MAP_FAILED
)
1140 FcCacheAddBankDir (metadata
.bank
, dir
);
1142 FcConfigAddFontDir (config
, (FcChar8
*)dir
);
1144 if (!FcFontSetUnserialize (&metadata
, set
, current_dir_block
))
1151 FcDirCacheProduce (FcFontSet
*set
, FcCache
*metadata
)
1153 void * current_dir_block
, * final_dir_block
;
1154 static unsigned int rand_state
= 0;
1155 int bank
, needed_bytes_no_align
;
1158 rand_state
= time(0L);
1159 bank
= rand_r(&rand_state
);
1161 while (FcCacheHaveBank(bank
))
1162 bank
= rand_r(&rand_state
);
1164 memset (metadata
, 0, sizeof(FcCache
));
1166 needed_bytes_no_align
= FcFontSetNeededBytes (set
);
1167 metadata
->count
= needed_bytes_no_align
+
1168 FcFontSetNeededBytesAlign ();
1169 metadata
->magic
= FC_CACHE_MAGIC
;
1170 metadata
->bank
= bank
;
1172 if (!needed_bytes_no_align
) /* not a failure, no fonts to write */
1174 /* no, you don't really need to write any bytes at all. */
1175 metadata
->count
= 0;
1179 current_dir_block
= malloc (metadata
->count
);
1180 if (!current_dir_block
)
1183 memset (current_dir_block
, 0, metadata
->count
);
1184 final_dir_block
= FcFontSetDistributeBytes (metadata
, current_dir_block
);
1186 if ((void *)((char *)current_dir_block
+metadata
->count
) < final_dir_block
)
1189 if (!FcFontSetSerialize (bank
, set
))
1192 return current_dir_block
;
1195 free (current_dir_block
);
1199 /* write serialized state to the cache file */
1201 FcDirCacheWrite (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
)
1205 int fd
, fd_orig
, i
, dirs_count
;
1208 off_t current_arch_start
= 0, truncate_to
;
1209 char name_buf
[FC_MAX_FILE_LEN
];
1212 char *current_arch_machine_name
, * header
;
1213 void *current_dir_block
= 0;
1215 dir
= FcConfigNormalizeFontDir (FcConfigGetCurrent(), dir
);
1219 cache_file
= (char *)FcStrPlus (dir
, (FcChar8
*) "/" FC_DIR_CACHE_FILE
);
1223 /* Ensure that we're not trampling a cache for some other dir. */
1224 /* This is slightly different from FcDirCacheOpen, since it
1225 * needs the filename, not the file descriptor. */
1226 fd
= -1; collisions
= 0;
1229 cache_hashed
= FcDirCacheHashName (cache_file
, collisions
++);
1235 fd
= open(cache_hashed
, O_RDONLY
);
1238 if(!FcCacheReadString (fd
, name_buf
, sizeof (name_buf
)) || !strlen(name_buf
))
1245 if (strcmp (name_buf
, cache_file
) != 0)
1249 current_dir_block
= FcDirCacheProduce (set
, &metadata
);
1251 if (metadata
.count
&& !current_dir_block
)
1254 if (FcDebug () & FC_DBG_CACHE
)
1255 printf ("FcDirCacheWriteDir cache_file \"%s\"\n", cache_file
);
1257 atomic
= FcAtomicCreate ((FcChar8
*)cache_hashed
);
1261 if (!FcAtomicLock (atomic
))
1263 /* Now try rewriting the original version of the file. */
1264 FcAtomicDestroy (atomic
);
1266 atomic
= FcAtomicCreate ((FcChar8
*)cache_file
);
1267 fd_orig
= open (cache_file
, O_RDONLY
);
1269 fd_orig
= open((char *)FcAtomicOrigFile (atomic
), O_RDONLY
);
1271 fd
= open((char *)FcAtomicNewFile (atomic
), O_RDWR
| O_CREAT
, 0666);
1276 /* In all cases, try opening the real location of the cache file first. */
1277 /* (even if that's not atomic.) */
1278 fd_orig
= open (cache_file
, O_RDONLY
);
1280 fd_orig
= open((char *)FcAtomicOrigFile (atomic
), O_RDONLY
);
1282 fd
= open((char *)FcAtomicNewFile (atomic
), O_RDWR
| O_CREAT
, 0666);
1286 FcCacheWriteString (fd
, cache_file
);
1288 current_arch_machine_name
= FcCacheMachineSignature ();
1289 current_arch_start
= 0;
1292 current_arch_start
=
1293 FcCacheSkipToArch(fd_orig
, current_arch_machine_name
);
1295 if (current_arch_start
< 0)
1297 off_t i
= lseek(fd_orig
, 0, SEEK_END
);
1298 if (i
< strlen (FC_GLOBAL_MAGIC_COOKIE
)+1)
1299 i
= strlen (FC_GLOBAL_MAGIC_COOKIE
)+1;
1300 current_arch_start
= FcCacheNextOffset (i
);
1303 if (fd_orig
!= -1 && !FcCacheCopyOld(fd
, fd_orig
, current_arch_start
))
1309 current_arch_start
= lseek(fd
, 0, SEEK_CUR
);
1310 if (ftruncate (fd
, current_arch_start
) == -1)
1313 /* allocate space for subdir names in this block */
1315 for (i
= 0; i
< dirs
->size
; i
++)
1316 dirs_count
+= strlen((char *)dirs
->strs
[i
]) + 1;
1319 /* now write the address of the next offset */
1320 truncate_to
= FcCacheNextOffset (FcCacheNextOffset (current_arch_start
+ sizeof (FcCache
) + dirs_count
) + metadata
.count
) - current_arch_start
;
1321 header
= malloc (10 + strlen (current_arch_machine_name
));
1324 sprintf (header
, "%8x ", (int)truncate_to
);
1325 strcat (header
, current_arch_machine_name
);
1326 if (!FcCacheWriteString (fd
, header
))
1329 for (i
= 0; i
< dirs
->size
; i
++)
1330 FcCacheWriteString (fd
, (char *)dirs
->strs
[i
]);
1331 FcCacheWriteString (fd
, "");
1333 if (write (fd
, &metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
1335 perror("write metadata");
1340 off_t off
= FcCacheNextOffset (lseek(fd
, 0, SEEK_END
));
1341 if (lseek (fd
, off
, SEEK_SET
) != off
)
1343 else if (write (fd
, current_dir_block
, metadata
.count
) !=
1345 perror("write current_dir_block");
1346 free (current_dir_block
);
1349 /* this actually serves to pad out the cache file, if needed */
1350 if (ftruncate (fd
, current_arch_start
+ truncate_to
) == -1)
1355 if (!FcAtomicReplaceOrig(atomic
))
1357 FcStrFree ((FcChar8
*)cache_hashed
);
1358 FcStrFree ((FcChar8
*)cache_file
);
1359 FcAtomicUnlock (atomic
);
1360 FcAtomicDestroy (atomic
);
1368 FcAtomicUnlock (atomic
);
1370 FcAtomicDestroy (atomic
);
1372 FcStrFree ((FcChar8
*)cache_hashed
);
1374 unlink ((char *)cache_file
);
1375 FcStrFree ((FcChar8
*)cache_file
);
1376 if (current_dir_block
)
1377 free (current_dir_block
);
1383 FcCacheMachineSignature ()
1385 static char buf
[MACHINE_SIGNATURE_SIZE
];
1386 int32_t magic
= ENDIAN_TEST
;
1387 char * m
= (char *)&magic
;
1389 sprintf (buf
, "%2x%2x%2x%2x "
1390 "%4x %4x %4x %4x %4x %4x %4x %4x %4x %4x %4x %4x "
1391 "%4x %4x %4x %4x %4x %4x %4x %4x\n",
1392 m
[0], m
[1], m
[2], m
[3],
1393 (unsigned int)sizeof (char),
1394 (unsigned int)sizeof (char *),
1395 (unsigned int)sizeof (int),
1396 (unsigned int)sizeof (FcPattern
),
1397 (unsigned int)sizeof (FcPatternEltPtr
),
1398 (unsigned int)sizeof (struct _FcPatternElt
*),
1399 (unsigned int)sizeof (FcPatternElt
),
1400 (unsigned int)sizeof (FcObjectPtr
),
1401 (unsigned int)sizeof (FcValueListPtr
),
1402 (unsigned int)sizeof (FcValue
),
1403 (unsigned int)sizeof (FcValueBinding
),
1404 (unsigned int)sizeof (struct _FcValueList
*),
1405 (unsigned int)sizeof (FcCharSet
),
1406 (unsigned int)sizeof (FcCharLeaf
**),
1407 (unsigned int)sizeof (FcChar16
*),
1408 (unsigned int)sizeof (FcChar16
),
1409 (unsigned int)sizeof (FcCharLeaf
),
1410 (unsigned int)sizeof (FcChar32
),
1411 (unsigned int)sizeof (FcCache
),
1412 (unsigned int)sysconf(_SC_PAGESIZE
));
1417 static int banks_ptr
= 0, banks_alloc
= 0;
1418 int * _fcBankId
= 0, * _fcBankIdx
= 0;
1419 static const char ** bankDirs
= 0;
1422 FcCacheHaveBank (int bank
)
1426 if (bank
< FC_BANK_FIRST
)
1429 for (i
= 0; i
< banks_ptr
; i
++)
1430 if (_fcBankId
[i
] == bank
)
1437 FcCacheBankToIndexMTF (int bank
)
1441 for (i
= 0; i
< banks_ptr
; i
++)
1442 if (_fcBankId
[_fcBankIdx
[i
]] == bank
)
1444 int t
= _fcBankIdx
[i
];
1446 for (j
= i
; j
> 0; j
--)
1447 _fcBankIdx
[j
] = _fcBankIdx
[j
-1];
1452 if (banks_ptr
>= banks_alloc
)
1457 b
= realloc (_fcBankId
, (banks_alloc
+ 4) * sizeof(int));
1462 bidx
= realloc (_fcBankIdx
, (banks_alloc
+ 4) * sizeof(int));
1467 bds
= realloc (bankDirs
, (banks_alloc
+ 4) * sizeof (char *));
1476 _fcBankId
[i
] = bank
;
1482 FcCacheAddBankDir (int bank
, const char * dir
)
1484 int bi
= FcCacheBankToIndexMTF (bank
);
1489 bankDirs
[bi
] = (const char *)FcStrCopy ((FcChar8
*)dir
);
1493 FcCacheFindBankDir (int bank
)
1495 int bi
= FcCacheBankToIndex (bank
);
1496 return bankDirs
[bi
];
1500 * This code implements the MD5 message-digest algorithm.
1501 * The algorithm is due to Ron Rivest. This code was
1502 * written by Colin Plumb in 1993, no copyright is claimed.
1503 * This code is in the public domain; do with it what you wish.
1505 * Equivalent code is available from RSA Data Security, Inc.
1506 * This code has been tested against that, and is equivalent,
1507 * except that you don't need to include two pages of legalese
1510 * To compute the message digest of a chunk of bytes, declare an
1511 * MD5Context structure, pass it to MD5Init, call MD5Update as
1512 * needed on buffers full of bytes, and then call MD5Final, which
1513 * will fill a supplied 16-byte array with the digest.
1517 #define byteReverse(buf, len) /* Nothing */
1520 * Note: this code is harmless on little-endian machines.
1522 void byteReverse(unsigned char *buf
, unsigned longs
)
1526 t
= (FcChar32
) ((unsigned) buf
[3] << 8 | buf
[2]) << 16 |
1527 ((unsigned) buf
[1] << 8 | buf
[0]);
1528 *(FcChar32
*) buf
= t
;
1535 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
1536 * initialization constants.
1538 static void MD5Init(struct MD5Context
*ctx
)
1540 ctx
->buf
[0] = 0x67452301;
1541 ctx
->buf
[1] = 0xefcdab89;
1542 ctx
->buf
[2] = 0x98badcfe;
1543 ctx
->buf
[3] = 0x10325476;
1550 * Update context to reflect the concatenation of another buffer full
1553 static void MD5Update(struct MD5Context
*ctx
, unsigned char *buf
, unsigned len
)
1557 /* Update bitcount */
1560 if ((ctx
->bits
[0] = t
+ ((FcChar32
) len
<< 3)) < t
)
1561 ctx
->bits
[1]++; /* Carry from low to high */
1562 ctx
->bits
[1] += len
>> 29;
1564 t
= (t
>> 3) & 0x3f; /* Bytes already in shsInfo->data */
1566 /* Handle any leading odd-sized chunks */
1569 unsigned char *p
= (unsigned char *) ctx
->in
+ t
;
1573 memcpy(p
, buf
, len
);
1577 byteReverse(ctx
->in
, 16);
1578 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1582 /* Process data in 64-byte chunks */
1585 memcpy(ctx
->in
, buf
, 64);
1586 byteReverse(ctx
->in
, 16);
1587 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1592 /* Handle any remaining bytes of data. */
1594 memcpy(ctx
->in
, buf
, len
);
1598 * Final wrapup - pad to 64-byte boundary with the bit pattern
1599 * 1 0* (64-bit count of bits processed, MSB-first)
1601 static void MD5Final(unsigned char digest
[16], struct MD5Context
*ctx
)
1606 /* Compute number of bytes mod 64 */
1607 count
= (ctx
->bits
[0] >> 3) & 0x3F;
1609 /* Set the first char of padding to 0x80. This is safe since there is
1610 always at least one byte free */
1611 p
= ctx
->in
+ count
;
1614 /* Bytes of padding needed to make 64 bytes */
1615 count
= 64 - 1 - count
;
1617 /* Pad out to 56 mod 64 */
1619 /* Two lots of padding: Pad the first block to 64 bytes */
1620 memset(p
, 0, count
);
1621 byteReverse(ctx
->in
, 16);
1622 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1624 /* Now fill the next block with 56 bytes */
1625 memset(ctx
->in
, 0, 56);
1627 /* Pad block to 56 bytes */
1628 memset(p
, 0, count
- 8);
1630 byteReverse(ctx
->in
, 14);
1632 /* Append length in bits and transform */
1633 ((FcChar32
*) ctx
->in
)[14] = ctx
->bits
[0];
1634 ((FcChar32
*) ctx
->in
)[15] = ctx
->bits
[1];
1636 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1637 byteReverse((unsigned char *) ctx
->buf
, 4);
1638 memcpy(digest
, ctx
->buf
, 16);
1639 memset(ctx
, 0, sizeof(ctx
)); /* In case it's sensitive */
1643 /* The four core functions - F1 is optimized somewhat */
1645 /* #define F1(x, y, z) (x & y | ~x & z) */
1646 #define F1(x, y, z) (z ^ (x & (y ^ z)))
1647 #define F2(x, y, z) F1(z, x, y)
1648 #define F3(x, y, z) (x ^ y ^ z)
1649 #define F4(x, y, z) (y ^ (x | ~z))
1651 /* This is the central step in the MD5 algorithm. */
1652 #define MD5STEP(f, w, x, y, z, data, s) \
1653 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
1656 * The core of the MD5 algorithm, this alters an existing MD5 hash to
1657 * reflect the addition of 16 longwords of new data. MD5Update blocks
1658 * the data and converts bytes into longwords for this routine.
1660 static void MD5Transform(FcChar32 buf
[4], FcChar32 in
[16])
1662 register FcChar32 a
, b
, c
, d
;
1669 MD5STEP(F1
, a
, b
, c
, d
, in
[0] + 0xd76aa478, 7);
1670 MD5STEP(F1
, d
, a
, b
, c
, in
[1] + 0xe8c7b756, 12);
1671 MD5STEP(F1
, c
, d
, a
, b
, in
[2] + 0x242070db, 17);
1672 MD5STEP(F1
, b
, c
, d
, a
, in
[3] + 0xc1bdceee, 22);
1673 MD5STEP(F1
, a
, b
, c
, d
, in
[4] + 0xf57c0faf, 7);
1674 MD5STEP(F1
, d
, a
, b
, c
, in
[5] + 0x4787c62a, 12);
1675 MD5STEP(F1
, c
, d
, a
, b
, in
[6] + 0xa8304613, 17);
1676 MD5STEP(F1
, b
, c
, d
, a
, in
[7] + 0xfd469501, 22);
1677 MD5STEP(F1
, a
, b
, c
, d
, in
[8] + 0x698098d8, 7);
1678 MD5STEP(F1
, d
, a
, b
, c
, in
[9] + 0x8b44f7af, 12);
1679 MD5STEP(F1
, c
, d
, a
, b
, in
[10] + 0xffff5bb1, 17);
1680 MD5STEP(F1
, b
, c
, d
, a
, in
[11] + 0x895cd7be, 22);
1681 MD5STEP(F1
, a
, b
, c
, d
, in
[12] + 0x6b901122, 7);
1682 MD5STEP(F1
, d
, a
, b
, c
, in
[13] + 0xfd987193, 12);
1683 MD5STEP(F1
, c
, d
, a
, b
, in
[14] + 0xa679438e, 17);
1684 MD5STEP(F1
, b
, c
, d
, a
, in
[15] + 0x49b40821, 22);
1686 MD5STEP(F2
, a
, b
, c
, d
, in
[1] + 0xf61e2562, 5);
1687 MD5STEP(F2
, d
, a
, b
, c
, in
[6] + 0xc040b340, 9);
1688 MD5STEP(F2
, c
, d
, a
, b
, in
[11] + 0x265e5a51, 14);
1689 MD5STEP(F2
, b
, c
, d
, a
, in
[0] + 0xe9b6c7aa, 20);
1690 MD5STEP(F2
, a
, b
, c
, d
, in
[5] + 0xd62f105d, 5);
1691 MD5STEP(F2
, d
, a
, b
, c
, in
[10] + 0x02441453, 9);
1692 MD5STEP(F2
, c
, d
, a
, b
, in
[15] + 0xd8a1e681, 14);
1693 MD5STEP(F2
, b
, c
, d
, a
, in
[4] + 0xe7d3fbc8, 20);
1694 MD5STEP(F2
, a
, b
, c
, d
, in
[9] + 0x21e1cde6, 5);
1695 MD5STEP(F2
, d
, a
, b
, c
, in
[14] + 0xc33707d6, 9);
1696 MD5STEP(F2
, c
, d
, a
, b
, in
[3] + 0xf4d50d87, 14);
1697 MD5STEP(F2
, b
, c
, d
, a
, in
[8] + 0x455a14ed, 20);
1698 MD5STEP(F2
, a
, b
, c
, d
, in
[13] + 0xa9e3e905, 5);
1699 MD5STEP(F2
, d
, a
, b
, c
, in
[2] + 0xfcefa3f8, 9);
1700 MD5STEP(F2
, c
, d
, a
, b
, in
[7] + 0x676f02d9, 14);
1701 MD5STEP(F2
, b
, c
, d
, a
, in
[12] + 0x8d2a4c8a, 20);
1703 MD5STEP(F3
, a
, b
, c
, d
, in
[5] + 0xfffa3942, 4);
1704 MD5STEP(F3
, d
, a
, b
, c
, in
[8] + 0x8771f681, 11);
1705 MD5STEP(F3
, c
, d
, a
, b
, in
[11] + 0x6d9d6122, 16);
1706 MD5STEP(F3
, b
, c
, d
, a
, in
[14] + 0xfde5380c, 23);
1707 MD5STEP(F3
, a
, b
, c
, d
, in
[1] + 0xa4beea44, 4);
1708 MD5STEP(F3
, d
, a
, b
, c
, in
[4] + 0x4bdecfa9, 11);
1709 MD5STEP(F3
, c
, d
, a
, b
, in
[7] + 0xf6bb4b60, 16);
1710 MD5STEP(F3
, b
, c
, d
, a
, in
[10] + 0xbebfbc70, 23);
1711 MD5STEP(F3
, a
, b
, c
, d
, in
[13] + 0x289b7ec6, 4);
1712 MD5STEP(F3
, d
, a
, b
, c
, in
[0] + 0xeaa127fa, 11);
1713 MD5STEP(F3
, c
, d
, a
, b
, in
[3] + 0xd4ef3085, 16);
1714 MD5STEP(F3
, b
, c
, d
, a
, in
[6] + 0x04881d05, 23);
1715 MD5STEP(F3
, a
, b
, c
, d
, in
[9] + 0xd9d4d039, 4);
1716 MD5STEP(F3
, d
, a
, b
, c
, in
[12] + 0xe6db99e5, 11);
1717 MD5STEP(F3
, c
, d
, a
, b
, in
[15] + 0x1fa27cf8, 16);
1718 MD5STEP(F3
, b
, c
, d
, a
, in
[2] + 0xc4ac5665, 23);
1720 MD5STEP(F4
, a
, b
, c
, d
, in
[0] + 0xf4292244, 6);
1721 MD5STEP(F4
, d
, a
, b
, c
, in
[7] + 0x432aff97, 10);
1722 MD5STEP(F4
, c
, d
, a
, b
, in
[14] + 0xab9423a7, 15);
1723 MD5STEP(F4
, b
, c
, d
, a
, in
[5] + 0xfc93a039, 21);
1724 MD5STEP(F4
, a
, b
, c
, d
, in
[12] + 0x655b59c3, 6);
1725 MD5STEP(F4
, d
, a
, b
, c
, in
[3] + 0x8f0ccc92, 10);
1726 MD5STEP(F4
, c
, d
, a
, b
, in
[10] + 0xffeff47d, 15);
1727 MD5STEP(F4
, b
, c
, d
, a
, in
[1] + 0x85845dd1, 21);
1728 MD5STEP(F4
, a
, b
, c
, d
, in
[8] + 0x6fa87e4f, 6);
1729 MD5STEP(F4
, d
, a
, b
, c
, in
[15] + 0xfe2ce6e0, 10);
1730 MD5STEP(F4
, c
, d
, a
, b
, in
[6] + 0xa3014314, 15);
1731 MD5STEP(F4
, b
, c
, d
, a
, in
[13] + 0x4e0811a1, 21);
1732 MD5STEP(F4
, a
, b
, c
, d
, in
[4] + 0xf7537e82, 6);
1733 MD5STEP(F4
, d
, a
, b
, c
, in
[11] + 0xbd3af235, 10);
1734 MD5STEP(F4
, c
, d
, a
, b
, in
[2] + 0x2ad7d2bb, 15);
1735 MD5STEP(F4
, b
, c
, d
, a
, in
[9] + 0xeb86d391, 21);