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
44 FcDirCacheOpen (const FcChar8
* dir
);
47 FcDirCacheHashName (char * cache_file
, int collisions
);
50 FcCacheSkipToArch (int fd
, const char * arch
);
53 FcCacheCopyOld (int fd
, int fd_orig
, off_t start
);
56 FcDirCacheProduce (FcFontSet
*set
, FcCache
* metadata
);
59 FcDirCacheConsume (int fd
, const char * dir
, FcFontSet
*set
, FcConfig
*config
);
62 FcCacheNextOffset(off_t w
);
65 FcCacheMachineSignature (void);
68 FcCacheHaveBank (int bank
);
71 FcCacheAddBankDir (int bank
, const char * dir
);
79 static void MD5Init(struct MD5Context
*ctx
);
80 static void MD5Update(struct MD5Context
*ctx
, unsigned char *buf
, unsigned len
);
81 static void MD5Final(unsigned char digest
[16], struct MD5Context
*ctx
);
82 static void MD5Transform(FcChar32 buf
[4], FcChar32 in
[16]);
84 #define FC_DBG_CACHE_REF 1024
87 FcCacheReadString (int fd
, char *dest
, int len
)
95 size
= read (fd
, dest
, len
-1);
100 slen
= strlen (dest
);
102 lseek (fd
, slen
- size
+ 1, SEEK_CUR
);
103 return slen
< len
? dest
: 0;
110 FcCacheSkipString (int fd
)
116 while ( (size
= read (fd
, buf
, sizeof (buf
)-1)) > 0)
122 lseek (fd
, slen
- size
+ 1, SEEK_CUR
);
129 FcCacheWriteString (int fd
, const char *chars
)
131 if (write (fd
, chars
, strlen(chars
)+1) != strlen(chars
)+1)
137 FcGlobalCacheDirDestroy (FcGlobalCacheDir
*d
)
139 FcStrSetDestroy (d
->subdirs
);
140 FcMemFree (FC_MEM_STRING
, strlen (d
->name
)+1);
142 FcMemFree (FC_MEM_CACHE
, sizeof (FcGlobalCacheDir
));
147 FcGlobalCacheCreate (void)
149 FcGlobalCache
*cache
;
151 cache
= malloc (sizeof (FcGlobalCache
));
154 FcMemAlloc (FC_MEM_CACHE
, sizeof (FcGlobalCache
));
156 cache
->updated
= FcFalse
;
162 FcGlobalCacheDestroy (FcGlobalCache
*cache
)
164 FcGlobalCacheDir
*d
, *next
;
166 for (d
= cache
->dirs
; d
; d
= next
)
169 FcGlobalCacheDirDestroy (d
);
171 FcMemFree (FC_MEM_CACHE
, sizeof (FcGlobalCache
));
176 FcGlobalCacheLoad (FcGlobalCache
*cache
,
178 const FcChar8
*cache_file
,
181 char name_buf
[FC_MAX_FILE_LEN
];
182 FcGlobalCacheDir
*d
, *next
;
183 FcFileTime config_time
= FcConfigModifiedTime (config
);
184 char * current_arch_machine_name
;
185 char candidate_arch_machine_name
[MACHINE_SIGNATURE_SIZE
+ 9];
186 off_t current_arch_start
;
188 struct stat cache_stat
, dir_stat
;
189 char subdirName
[FC_MAX_FILE_LEN
+ 1 + 12 + 1];
191 if (stat ((char *) cache_file
, &cache_stat
) < 0)
194 cache
->fd
= open ((char *) cache_file
, O_RDONLY
| O_BINARY
);
198 cache
->updated
= FcFalse
;
200 if (!FcCacheReadString (cache
->fd
, name_buf
, sizeof (name_buf
)))
201 goto bail_and_destroy
;
202 if (strcmp (name_buf
, FC_GLOBAL_MAGIC_COOKIE
) != 0)
203 goto bail_and_destroy
;
205 current_arch_machine_name
= FcCacheMachineSignature ();
206 current_arch_start
= FcCacheSkipToArch(cache
->fd
,
207 current_arch_machine_name
);
208 if (current_arch_start
< 0)
209 goto bail_and_destroy
;
211 lseek (cache
->fd
, current_arch_start
, SEEK_SET
);
212 if (!FcCacheReadString (cache
->fd
, candidate_arch_machine_name
,
213 sizeof (candidate_arch_machine_name
)))
214 goto bail_and_destroy
;
215 if (strlen(candidate_arch_machine_name
) == 0)
216 goto bail_and_destroy
;
222 if (!FcCacheReadString (cache
->fd
, name_buf
, sizeof (name_buf
)) ||
226 /* Directory must be older than the global cache file; also
227 cache must be newer than the config file. */
228 if (stat ((char *) name_buf
, &dir_stat
) < 0 ||
229 dir_stat
.st_mtime
> cache_stat
.st_mtime
||
230 (config_time
.set
&& cache_stat
.st_mtime
< config_time
.time
))
235 FcStrSetAdd (staleDirs
, FcStrCopy ((FcChar8
*)name_buf
));
238 while (FcCacheReadString (cache
->fd
, subdirName
,
239 sizeof (subdirName
)) &&
243 if (read (cache
->fd
, &md
, sizeof (FcCache
)) != sizeof(FcCache
))
245 perror ("read metadata");
248 off
= FcCacheNextOffset (lseek(cache
->fd
, 0, SEEK_CUR
)) + md
.count
;
249 if (lseek (cache
->fd
, off
, SEEK_SET
) != off
)
257 d
= malloc (sizeof (FcGlobalCacheDir
));
261 d
->next
= cache
->dirs
;
264 d
->name
= (char *)FcStrCopy ((FcChar8
*)name_buf
);
266 d
->state
= FcGCDirFileRead
;
268 d
->subdirs
= FcStrSetCreate();
271 if (!FcCacheReadString (cache
->fd
, subdirName
,
272 sizeof (subdirName
)) ||
273 !strlen (subdirName
))
275 FcStrSetAdd (d
->subdirs
, (FcChar8
*)subdirName
);
278 d
->offset
= lseek (cache
->fd
, 0, SEEK_CUR
);
279 if (read (cache
->fd
, &d
->metadata
, sizeof (FcCache
)) != sizeof (FcCache
))
281 targ
= FcCacheNextOffset (lseek(cache
->fd
, 0, SEEK_CUR
)) + d
->metadata
.count
;
282 if (lseek (cache
->fd
, targ
, SEEK_SET
) != targ
)
288 for (d
= cache
->dirs
; d
; d
= next
)
303 if (stat ((char *) cache_file
, &cache_stat
) == 0)
304 unlink ((char *)cache_file
);
311 FcGlobalCacheReadDir (FcFontSet
*set
, FcStrSet
*dirs
, FcGlobalCache
* cache
, const char *dir
, FcConfig
*config
)
319 if (!(dir
= (char *)FcConfigNormalizeFontDir (config
, (FcChar8
*)dir
)))
320 return FcFalse
; /* non-existing directory */
322 for (d
= cache
->dirs
; d
; d
= d
->next
)
324 if (strcmp (d
->name
, dir
) == 0)
326 if (d
->state
== FcGCDirDisabled
)
329 if (d
->state
== FcGCDirFileRead
)
331 lseek (cache
->fd
, d
->offset
, SEEK_SET
);
332 if (!FcDirCacheConsume (cache
->fd
, d
->name
, set
, config
))
335 for (i
= 0; i
< d
->subdirs
->num
; i
++)
336 FcStrSetAdd (dirs
, (FcChar8
*)d
->subdirs
->strs
[i
]);
338 d
->state
= FcGCDirConsumed
;
347 static FcGlobalCacheDir
*
348 FcGlobalCacheDirFind (FcGlobalCache
*cache
, const char *name
)
350 FcGlobalCacheDir
* d
;
355 for (d
= cache
->dirs
; d
; d
= d
->next
)
356 if (strcmp((const char *)d
->name
, (const char *)name
) == 0)
363 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
365 const char *orig_name
,
373 name
= (char *)FcConfigNormalizeFontDir (config
, (FcChar8
*)orig_name
);
376 fprintf(stderr
, "Invalid directory name %s\n", orig_name
);
380 d
= FcGlobalCacheDirFind (cache
, name
);
384 d
= malloc (sizeof (FcGlobalCacheDir
));
387 d
->next
= cache
->dirs
;
390 /* free old resources */
391 FcStrFree ((FcChar8
*)d
->name
);
393 FcStrSetDestroy (d
->subdirs
);
396 cache
->updated
= FcTrue
;
398 d
->name
= (char *)FcStrCopy ((FcChar8
*)name
);
399 d
->ent
= FcDirCacheProduce (set
, &d
->metadata
);
401 d
->subdirs
= FcStrSetCreate();
402 d
->state
= FcGCDirUpdated
;
403 for (i
= 0; i
< dirs
->num
; i
++)
404 FcStrSetAdd (d
->subdirs
, dirs
->strs
[i
]);
409 FcGlobalCacheSave (FcGlobalCache
*cache
,
410 const FcChar8
*cache_file
,
414 FcGlobalCacheDir
*dir
;
416 off_t current_arch_start
= 0, truncate_to
;
417 char * current_arch_machine_name
, * header
;
422 #if defined (HAVE_GETUID) && defined (HAVE_GETEUID)
423 /* Set-UID programs can't safely update the cache */
424 if (getuid () != geteuid ())
428 atomic
= FcAtomicCreate (cache_file
);
432 if (!FcAtomicLock (atomic
))
434 fd
= open ((char *) FcAtomicNewFile(atomic
), O_RDWR
| O_CREAT
| O_BINARY
,
438 FcCacheWriteString (fd
, FC_GLOBAL_MAGIC_COOKIE
);
440 fd_orig
= open ((char *) FcAtomicOrigFile(atomic
), O_RDONLY
| O_BINARY
);
442 current_arch_machine_name
= FcCacheMachineSignature ();
444 current_arch_start
= 0;
446 current_arch_start
= FcCacheSkipToArch (fd_orig
,
447 current_arch_machine_name
);
449 if (current_arch_start
< 0)
451 off_t i
= lseek(fd_orig
, 0, SEEK_END
);
452 if (i
< strlen (FC_GLOBAL_MAGIC_COOKIE
)+1)
453 i
= strlen (FC_GLOBAL_MAGIC_COOKIE
)+1;
454 current_arch_start
= FcCacheNextOffset (i
);
457 if (!FcCacheCopyOld(fd
, fd_orig
, current_arch_start
))
460 current_arch_start
= lseek(fd
, 0, SEEK_CUR
);
461 if (ftruncate (fd
, current_arch_start
) == -1)
464 header
= malloc (10 + strlen (current_arch_machine_name
));
468 truncate_to
= current_arch_start
+ strlen(current_arch_machine_name
) + 11;
469 for (dir
= cache
->dirs
; dir
; dir
= dir
->next
)
471 if (dir
->state
== FcGCDirDisabled
)
473 truncate_to
+= strlen(dir
->name
) + 1;
474 truncate_to
+= sizeof (FcCache
);
475 truncate_to
= FcCacheNextOffset (truncate_to
);
476 truncate_to
+= dir
->metadata
.count
;
478 for (i
= 0; i
< dir
->subdirs
->size
; i
++)
479 truncate_to
+= strlen((char *)dir
->subdirs
->strs
[i
]) + 1;
482 truncate_to
-= current_arch_start
;
484 sprintf (header
, "%8x ", (int)truncate_to
);
485 strcat (header
, current_arch_machine_name
);
486 if (!FcCacheWriteString (fd
, header
))
489 for (dir
= cache
->dirs
; dir
; dir
= dir
->next
)
494 if (!dir
->name
|| dir
->state
== FcGCDirDisabled
)
496 d
= (const char *)FcConfigNormalizeFontDir (config
, (const FcChar8
*)dir
->name
);
500 if (dir
->metadata
.count
&& !dir
->ent
)
502 if (dir
->state
== FcGCDirUpdated
|| fd_orig
< 0)
504 fprintf(stderr
, "Invalid metadata entry for %s, skipping...\n", d
);
507 /* copy the old content */
508 dir
->ent
= malloc (dir
->metadata
.count
);
511 perror("malloc error");
514 off
= FcCacheNextOffset (dir
->offset
+ sizeof(FcCache
));
515 if (lseek (fd_orig
, off
, SEEK_SET
) != off
)
521 if (read (fd_orig
, dir
->ent
, dir
->metadata
.count
)
522 != dir
->metadata
.count
)
530 FcCacheWriteString (fd
, d
);
532 for (i
= 0; i
< dir
->subdirs
->size
; i
++)
533 FcCacheWriteString (fd
, (char *)dir
->subdirs
->strs
[i
]);
534 FcCacheWriteString (fd
, "");
536 if (write (fd
, &dir
->metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
538 perror ("write metadata");
542 off
= FcCacheNextOffset (lseek(fd
, 0, SEEK_CUR
));
543 if (lseek (fd
, off
, SEEK_SET
) != off
)
549 if (dir
->metadata
.count
)
551 if (write (fd
, dir
->ent
, dir
->metadata
.count
) != dir
->metadata
.count
)
553 perror ("write dirent");
560 FcCacheWriteString (fd
, "");
562 if (close (fd
) == -1)
568 if (!FcAtomicReplaceOrig (atomic
))
571 FcAtomicUnlock (atomic
);
572 FcAtomicDestroy (atomic
);
574 cache
->updated
= FcFalse
;
585 FcAtomicDeleteNew (atomic
);
587 FcAtomicUnlock (atomic
);
589 FcAtomicDestroy (atomic
);
594 * Find the next presumably-mmapable offset after the supplied file
598 FcCacheNextOffset(off_t w
)
600 static long pagesize
= -1;
602 pagesize
= sysconf(_SC_PAGESIZE
);
603 if (w
% pagesize
== 0)
606 return ((w
/ pagesize
)+1)*pagesize
;
609 /* return the address of the segment for the provided arch,
610 * or -1 if arch not found */
612 FcCacheSkipToArch (int fd
, const char * arch
)
614 char candidate_arch_machine_name_count
[MACHINE_SIGNATURE_SIZE
+ 9];
615 char * candidate_arch
;
616 off_t current_arch_start
= 0;
618 lseek (fd
, 0, SEEK_SET
);
619 FcCacheSkipString (fd
);
620 current_arch_start
= lseek (fd
, 0, SEEK_CUR
);
622 /* skip arches that are not the current arch */
627 if (lseek (fd
, current_arch_start
, SEEK_SET
) != current_arch_start
)
630 if (FcCacheReadString (fd
, candidate_arch_machine_name_count
,
631 sizeof (candidate_arch_machine_name_count
)) == 0)
633 if (!strlen(candidate_arch_machine_name_count
))
635 bs
= strtol(candidate_arch_machine_name_count
, &candidate_arch
, 16);
637 // count = 0 should probably be distinguished from the !bs condition
638 if (!bs
|| bs
< strlen (candidate_arch_machine_name_count
))
641 candidate_arch
++; /* skip leading space */
643 if (strcmp (candidate_arch
, arch
)==0)
644 return current_arch_start
;
645 current_arch_start
+= bs
;
651 /* Cuts out the segment at the file pointer (moves everything else
652 * down to cover it), and leaves the file pointer at the end of the
655 FcCacheCopyOld (int fd
, int fd_orig
, off_t start
)
657 char * buf
= malloc (8192);
658 char candidate_arch_machine_name
[MACHINE_SIGNATURE_SIZE
+ 9];
660 int c
, bytes_skipped
;
667 lseek (fd
, 0, SEEK_SET
); lseek (fd_orig
, 0, SEEK_SET
);
668 FcCacheSkipString (fd
); FcCacheSkipString (fd_orig
);
675 if ((c
= read (fd_orig
, buf
, b
)) <= 0)
677 if (write (fd
, buf
, c
) < 0)
684 lseek (fd
, start
, SEEK_SET
);
685 if (FcCacheReadString (fd
, candidate_arch_machine_name
,
686 sizeof (candidate_arch_machine_name
)) == 0)
688 if (!strlen(candidate_arch_machine_name
))
691 bs
= strtol(candidate_arch_machine_name
, 0, 16);
698 lseek (fd
, start
+bs
+bytes_skipped
, SEEK_SET
);
699 if ((c
= read (fd
, buf
, 8192)) <= 0)
701 lseek (fd
, start
+bytes_skipped
, SEEK_SET
);
702 if (write (fd
, buf
, c
) < 0)
707 lseek (fd
, start
+bytes_skipped
, SEEK_SET
);
718 /* Does not check that the cache has the appropriate arch section. */
719 /* Also, this can be fooled if the original location has a stale
720 * cache, and the hashed location has an up-to-date cache. Oh well,
721 * sucks to be you in that case! */
723 FcDirCacheValid (const FcChar8
*dir
)
725 struct stat file_stat
, dir_stat
;
728 if (stat ((char *) dir
, &dir_stat
) < 0)
731 fd
= FcDirCacheOpen (dir
);
735 if (fstat (fd
, &file_stat
) < 0)
741 * If the directory has been modified more recently than
742 * the cache file, the cache is not valid
744 if (dir_stat
.st_mtime
> file_stat
.st_mtime
)
754 /* Assumes that the cache file in 'dir' exists.
755 * Checks that the cache has the appropriate arch section. */
757 FcDirCacheHasCurrentArch (const FcChar8
*dir
)
760 off_t current_arch_start
;
761 char *current_arch_machine_name
;
764 fd
= FcDirCacheOpen (dir
);
768 current_arch_machine_name
= FcCacheMachineSignature();
769 current_arch_start
= FcCacheSkipToArch(fd
, current_arch_machine_name
);
771 if (current_arch_start
>= 0)
773 if (read(fd
, &metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
779 if (metadata
.magic
!= FC_CACHE_MAGIC
)
788 if (current_arch_start
< 0)
798 FcDirCacheUnlink (const FcChar8
*dir
, FcConfig
*config
)
801 char *cache_hashed
= 0;
803 struct stat cache_stat
;
804 char name_buf
[FC_MAX_FILE_LEN
];
806 dir
= FcConfigNormalizeFontDir (config
, dir
);
807 cache_file
= (char *)FcStrPlus (dir
, (FcChar8
*) "/" FC_DIR_CACHE_FILE
);
811 /* First remove normal cache file. */
812 if (stat ((char *) cache_file
, &cache_stat
) == 0)
813 unlink ((char *)cache_file
);
815 /* Next remove any applicable hashed files. */
816 fd
= -1; collisions
= 0;
820 FcStrFree ((FcChar8
*)cache_hashed
);
822 cache_hashed
= FcDirCacheHashName (cache_file
, collisions
++);
828 fd
= open(cache_hashed
, O_RDONLY
| O_BINARY
);
831 FcStrFree ((FcChar8
*)cache_file
);
835 if (!FcCacheReadString (fd
, name_buf
, sizeof (name_buf
)) || !strlen(name_buf
))
837 FcStrFree ((FcChar8
*)cache_hashed
);
840 } while (strcmp (name_buf
, cache_file
) != 0);
844 if (stat ((char *) cache_hashed
, &cache_stat
) == 0 &&
845 unlink ((char *)cache_hashed
) != 0)
847 FcStrFree ((FcChar8
*)cache_hashed
);
851 FcStrFree ((FcChar8
*)cache_file
);
852 FcStrFree ((FcChar8
*)cache_hashed
);
856 FcStrFree ((FcChar8
*)cache_file
);
861 FcCacheReadDirs (FcConfig
* config
, FcGlobalCache
* cache
,
862 FcStrList
*list
, FcFontSet
* set
, FcStrSet
*processed_dirs
)
872 * Read in the results from 'list'.
874 while ((dir
= FcStrListNext (list
)))
876 if (!FcConfigAcceptFilename (config
, dir
))
879 /* Skip this directory if already updated
880 * to avoid the looped directories via symlinks
881 * Clearly a dir not in fonts.conf shouldn't be globally cached.
883 dir
= (FcChar8
*)FcConfigNormalizeFontDir (config
, dir
);
887 if (FcStrSetMember (processed_dirs
, dir
))
889 if (!FcStrSetAdd (processed_dirs
, dir
))
892 subdirs
= FcStrSetCreate ();
895 fprintf (stderr
, "Can't create directory set\n");
900 if (access ((char *) dir
, X_OK
) < 0)
908 fprintf (stderr
, "\"%s\": ", dir
);
912 FcStrSetDestroy (subdirs
);
915 if (stat ((char *) dir
, &statb
) == -1)
917 fprintf (stderr
, "\"%s\": ", dir
);
919 FcStrSetDestroy (subdirs
);
923 if (!S_ISDIR (statb
.st_mode
))
925 fprintf (stderr
, "\"%s\": not a directory, skipping\n", dir
);
926 FcStrSetDestroy (subdirs
);
929 if (FcDirCacheValid (dir
) && FcDirCacheRead (set
, subdirs
, dir
, config
))
931 /* if an old entry is found in the global cache, disable it */
932 if ((d
= FcGlobalCacheDirFind (cache
, (const char *)dir
)) != NULL
)
934 d
->state
= FcGCDirDisabled
;
935 /* save the updated config later without this entry */
936 cache
->updated
= FcTrue
;
941 if (FcDebug () & FC_DBG_FONTSET
)
942 printf ("cache scan dir %s\n", dir
);
944 FcDirScanConfig (set
, subdirs
, cache
,
945 config
->blanks
, dir
, FcFalse
, config
);
947 sublist
= FcStrListCreate (subdirs
);
948 FcStrSetDestroy (subdirs
);
951 fprintf (stderr
, "Can't create subdir list in \"%s\"\n", dir
);
955 ret
+= FcCacheReadDirs (config
, cache
, sublist
, set
, processed_dirs
);
957 FcStrListDone (list
);
962 FcCacheRead (FcConfig
*config
, FcGlobalCache
* cache
)
964 FcFontSet
*s
= FcFontSetCreate();
965 FcStrSet
*processed_dirs
;
970 processed_dirs
= FcStrSetCreate();
974 if (FcCacheReadDirs (config
, cache
, FcConfigGetConfigDirs (config
), s
, processed_dirs
))
977 FcStrSetDestroy (processed_dirs
);
981 FcStrSetDestroy (processed_dirs
);
983 FcFontSetDestroy (s
);
987 static const char bin2hex
[] = { '0', '1', '2', '3',
990 'c', 'd', 'e', 'f' };
993 FcDirCacheHashName (char * cache_file
, int collisions
)
995 unsigned char hash
[16], hex_hash
[33];
997 unsigned char uscore
= '_';
1000 struct MD5Context ctx
;
1003 MD5Update (&ctx
, (unsigned char *)cache_file
, strlen (cache_file
));
1005 for (i
= 0; i
< collisions
; i
++)
1006 MD5Update (&ctx
, &uscore
, 1);
1008 MD5Final (hash
, &ctx
);
1010 for (cnt
= 0; cnt
< 16; ++cnt
)
1012 hex_hash
[2*cnt
] = bin2hex
[hash
[cnt
] >> 4];
1013 hex_hash
[2*cnt
+1] = bin2hex
[hash
[cnt
] & 0xf];
1017 tmp
= FcStrPlus ((FcChar8
*)hex_hash
, (FcChar8
*)FC_CACHE_SUFFIX
);
1021 cache_hashed
= (char *)FcStrPlus ((FcChar8
*)PKGCACHEDIR
"/", tmp
);
1024 return cache_hashed
;
1027 /* Opens the hashed name for cache_file.
1028 * This would fail in the unlikely event of a collision and subsequent
1029 * removal of the file which originally caused the collision. */
1031 FcDirCacheOpen (const FcChar8
*dir
)
1034 int fd
= -1, collisions
= 0;
1035 char *cache_file
, *cache_hashed
;
1036 char name_buf
[FC_MAX_FILE_LEN
];
1037 struct stat dir_stat
;
1039 if (stat ((char *)dir
, &dir_stat
) == -1)
1042 cache_file
= (char *)FcStrPlus (dir
, (FcChar8
*) "/" FC_DIR_CACHE_FILE
);
1050 FcChar8
*name_buf_dir
;
1055 cache_hashed
= FcDirCacheHashName (cache_file
, collisions
++);
1058 FcStrFree ((FcChar8
*)cache_file
);
1062 fd
= open(cache_hashed
, O_RDONLY
| O_BINARY
);
1063 FcStrFree ((FcChar8
*)cache_hashed
);
1067 if (!FcCacheReadString (fd
, name_buf
, sizeof (name_buf
)) ||
1071 name_buf_dir
= FcStrDirname ((FcChar8
*)name_buf
);
1072 if (stat ((char *)name_buf_dir
, &c
) == -1)
1074 FcStrFree (name_buf_dir
);
1077 FcStrFree (name_buf_dir
);
1078 found
= (c
.st_ino
== dir_stat
.st_ino
) && (c
.st_dev
== dir_stat
.st_dev
);
1081 if (!found
|| fd
< 0)
1085 fd
= open(cache_file
, O_RDONLY
| O_BINARY
);
1088 FcStrFree ((FcChar8
*)cache_file
);
1092 /* read serialized state from the cache file */
1094 FcDirCacheRead (FcFontSet
* set
, FcStrSet
* dirs
, const FcChar8
*dir
, FcConfig
*config
)
1097 char *current_arch_machine_name
;
1098 char candidate_arch_machine_name
[9+MACHINE_SIGNATURE_SIZE
];
1099 off_t current_arch_start
= 0;
1100 char subdirName
[FC_MAX_FILE_LEN
+ 1 + 12 + 1];
1102 fd
= FcDirCacheOpen (dir
);
1106 current_arch_machine_name
= FcCacheMachineSignature();
1107 current_arch_start
= FcCacheSkipToArch(fd
,
1108 current_arch_machine_name
);
1109 if (current_arch_start
< 0)
1112 lseek (fd
, current_arch_start
, SEEK_SET
);
1113 if (FcCacheReadString (fd
, candidate_arch_machine_name
,
1114 sizeof (candidate_arch_machine_name
)) == 0)
1117 while (FcCacheReadString (fd
, subdirName
, sizeof (subdirName
)) && strlen (subdirName
) > 0)
1118 FcStrSetAdd (dirs
, (FcChar8
*)subdirName
);
1120 if (!FcDirCacheConsume (fd
, (const char *)dir
, set
, config
))
1133 FcDirCacheConsume (int fd
, const char * dir
, FcFontSet
*set
, FcConfig
*config
)
1136 void * current_dir_block
;
1139 if (read(fd
, &metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
1141 if (metadata
.magic
!= FC_CACHE_MAGIC
)
1144 if (!metadata
.count
)
1146 pos
= FcCacheNextOffset (lseek(fd
, 0, SEEK_CUR
));
1147 lseek (fd
, pos
, SEEK_SET
);
1149 FcConfigAddFontDir (config
, (FcChar8
*)dir
);
1153 pos
= FcCacheNextOffset (lseek(fd
, 0, SEEK_CUR
));
1154 current_dir_block
= mmap (0, metadata
.count
,
1155 PROT_READ
, MAP_SHARED
, fd
, pos
);
1156 lseek (fd
, pos
+metadata
.count
, SEEK_SET
);
1157 if (current_dir_block
== MAP_FAILED
)
1160 FcCacheAddBankDir (metadata
.bank
, dir
);
1162 FcConfigAddFontDir (config
, (FcChar8
*)dir
);
1164 if (!FcFontSetUnserialize (&metadata
, set
, current_dir_block
))
1171 FcDirCacheProduce (FcFontSet
*set
, FcCache
*metadata
)
1173 void * current_dir_block
, * final_dir_block
;
1174 static unsigned int rand_state
= 0;
1175 int bank
, needed_bytes_no_align
;
1178 rand_state
= time(0L);
1179 bank
= rand_r(&rand_state
);
1181 while (FcCacheHaveBank(bank
))
1182 bank
= rand_r(&rand_state
);
1184 memset (metadata
, 0, sizeof(FcCache
));
1186 needed_bytes_no_align
= FcFontSetNeededBytes (set
);
1187 metadata
->count
= needed_bytes_no_align
+
1188 FcFontSetNeededBytesAlign ();
1189 metadata
->magic
= FC_CACHE_MAGIC
;
1190 metadata
->bank
= bank
;
1192 if (!needed_bytes_no_align
) /* not a failure, no fonts to write */
1194 /* no, you don't really need to write any bytes at all. */
1195 metadata
->count
= 0;
1199 current_dir_block
= malloc (metadata
->count
);
1200 if (!current_dir_block
)
1203 memset (current_dir_block
, 0, metadata
->count
);
1204 final_dir_block
= FcFontSetDistributeBytes (metadata
, current_dir_block
);
1206 if ((void *)((char *)current_dir_block
+metadata
->count
) < final_dir_block
)
1209 if (!FcFontSetSerialize (bank
, set
))
1212 return current_dir_block
;
1215 free (current_dir_block
);
1219 /* write serialized state to the cache file */
1221 FcDirCacheWrite (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
)
1225 int fd
, fd_orig
, i
, dirs_count
;
1228 off_t current_arch_start
= 0, truncate_to
;
1229 char name_buf
[FC_MAX_FILE_LEN
];
1232 char *current_arch_machine_name
, * header
;
1233 void *current_dir_block
= 0;
1235 dir
= FcConfigNormalizeFontDir (FcConfigGetCurrent(), dir
);
1239 cache_file
= (char *)FcStrPlus (dir
, (FcChar8
*) "/" FC_DIR_CACHE_FILE
);
1243 /* Ensure that we're not trampling a cache for some other dir. */
1244 /* This is slightly different from FcDirCacheOpen, since it
1245 * needs the filename, not the file descriptor. */
1246 fd
= -1; collisions
= 0;
1249 cache_hashed
= FcDirCacheHashName (cache_file
, collisions
++);
1255 fd
= open(cache_hashed
, O_RDONLY
| O_BINARY
);
1258 if(!FcCacheReadString (fd
, name_buf
, sizeof (name_buf
)) || !strlen(name_buf
))
1265 if (strcmp (name_buf
, cache_file
) != 0)
1271 current_dir_block
= FcDirCacheProduce (set
, &metadata
);
1273 if (metadata
.count
&& !current_dir_block
)
1276 if (FcDebug () & FC_DBG_CACHE
)
1277 printf ("FcDirCacheWriteDir cache_file \"%s\"\n", cache_file
);
1279 atomic
= FcAtomicCreate ((FcChar8
*)cache_hashed
);
1283 if (!FcAtomicLock (atomic
))
1285 /* Now try rewriting the original version of the file. */
1286 FcAtomicDestroy (atomic
);
1288 atomic
= FcAtomicCreate ((FcChar8
*)cache_file
);
1289 fd_orig
= open (cache_file
, O_RDONLY
| O_BINARY
);
1291 fd_orig
= open((char *)FcAtomicOrigFile (atomic
), O_RDONLY
| O_BINARY
);
1293 fd
= open((char *)FcAtomicNewFile (atomic
), O_RDWR
| O_CREAT
| O_BINARY
, 0666);
1298 /* In all cases, try opening the real location of the cache file first. */
1299 /* (even if that's not atomic.) */
1300 fd_orig
= open (cache_file
, O_RDONLY
| O_BINARY
);
1302 fd_orig
= open((char *)FcAtomicOrigFile (atomic
), O_RDONLY
| O_BINARY
);
1304 fd
= open((char *)FcAtomicNewFile (atomic
), O_RDWR
| O_CREAT
| O_BINARY
, 0666);
1308 FcCacheWriteString (fd
, cache_file
);
1310 current_arch_machine_name
= FcCacheMachineSignature ();
1311 current_arch_start
= 0;
1314 current_arch_start
=
1315 FcCacheSkipToArch(fd_orig
, current_arch_machine_name
);
1317 if (current_arch_start
< 0)
1319 off_t i
= lseek(fd_orig
, 0, SEEK_END
);
1320 current_arch_start
= FcCacheNextOffset (i
);
1323 if (fd_orig
!= -1 && !FcCacheCopyOld(fd
, fd_orig
, current_arch_start
))
1329 current_arch_start
= lseek(fd
, 0, SEEK_CUR
);
1330 if (ftruncate (fd
, current_arch_start
) == -1)
1333 /* allocate space for subdir names in this block */
1335 for (i
= 0; i
< dirs
->size
; i
++)
1336 dirs_count
+= strlen((char *)dirs
->strs
[i
]) + 1;
1339 /* now write the address of the next offset */
1340 truncate_to
= FcCacheNextOffset (FcCacheNextOffset (current_arch_start
+ sizeof (FcCache
) + dirs_count
) + metadata
.count
) - current_arch_start
;
1341 header
= malloc (10 + strlen (current_arch_machine_name
));
1344 sprintf (header
, "%8x ", (int)truncate_to
);
1345 strcat (header
, current_arch_machine_name
);
1346 if (!FcCacheWriteString (fd
, header
))
1349 for (i
= 0; i
< dirs
->size
; i
++)
1350 FcCacheWriteString (fd
, (char *)dirs
->strs
[i
]);
1351 FcCacheWriteString (fd
, "");
1353 if (write (fd
, &metadata
, sizeof(FcCache
)) != sizeof(FcCache
))
1355 perror("write metadata");
1360 off_t off
= FcCacheNextOffset (lseek(fd
, 0, SEEK_END
));
1361 if (lseek (fd
, off
, SEEK_SET
) != off
)
1363 else if (write (fd
, current_dir_block
, metadata
.count
) !=
1365 perror("write current_dir_block");
1366 free (current_dir_block
);
1369 /* this actually serves to pad out the cache file, if needed */
1370 if (ftruncate (fd
, current_arch_start
+ truncate_to
) == -1)
1375 if (!FcAtomicReplaceOrig(atomic
))
1377 FcStrFree ((FcChar8
*)cache_hashed
);
1378 FcStrFree ((FcChar8
*)cache_file
);
1379 FcAtomicUnlock (atomic
);
1380 FcAtomicDestroy (atomic
);
1388 FcAtomicUnlock (atomic
);
1390 FcAtomicDestroy (atomic
);
1392 FcStrFree ((FcChar8
*)cache_hashed
);
1394 unlink ((char *)cache_file
);
1395 FcStrFree ((FcChar8
*)cache_file
);
1396 if (current_dir_block
)
1397 free (current_dir_block
);
1403 FcCacheMachineSignature ()
1405 static char buf
[MACHINE_SIGNATURE_SIZE
];
1406 int32_t magic
= ENDIAN_TEST
;
1407 char * m
= (char *)&magic
;
1409 sprintf (buf
, "%2x%2x%2x%2x "
1410 "%4x %4x %4x %4x %4x %4x %4x %4x %4x %4x %4x %4x "
1411 "%4x %4x %4x %4x %4x %4x %4x %4x\n",
1412 m
[0], m
[1], m
[2], m
[3],
1413 (unsigned int)sizeof (char),
1414 (unsigned int)sizeof (char *),
1415 (unsigned int)sizeof (int),
1416 (unsigned int)sizeof (FcPattern
),
1417 (unsigned int)sizeof (FcPatternEltPtr
),
1418 (unsigned int)sizeof (struct _FcPatternElt
*),
1419 (unsigned int)sizeof (FcPatternElt
),
1420 (unsigned int)sizeof (FcObjectPtr
),
1421 (unsigned int)sizeof (FcValueListPtr
),
1422 (unsigned int)sizeof (FcValue
),
1423 (unsigned int)sizeof (FcValueBinding
),
1424 (unsigned int)sizeof (struct _FcValueList
*),
1425 (unsigned int)sizeof (FcCharSet
),
1426 (unsigned int)sizeof (FcCharLeaf
**),
1427 (unsigned int)sizeof (FcChar16
*),
1428 (unsigned int)sizeof (FcChar16
),
1429 (unsigned int)sizeof (FcCharLeaf
),
1430 (unsigned int)sizeof (FcChar32
),
1431 (unsigned int)sizeof (FcCache
),
1432 (unsigned int)sysconf(_SC_PAGESIZE
));
1437 static int banks_ptr
= 0, banks_alloc
= 0;
1438 int * _fcBankId
= 0, * _fcBankIdx
= 0;
1439 static const char ** bankDirs
= 0;
1442 FcCacheHaveBank (int bank
)
1446 if (bank
< FC_BANK_FIRST
)
1449 for (i
= 0; i
< banks_ptr
; i
++)
1450 if (_fcBankId
[i
] == bank
)
1457 FcCacheBankToIndexMTF (int bank
)
1461 for (i
= 0; i
< banks_ptr
; i
++)
1462 if (_fcBankId
[_fcBankIdx
[i
]] == bank
)
1464 int t
= _fcBankIdx
[i
];
1466 for (j
= i
; j
> 0; j
--)
1467 _fcBankIdx
[j
] = _fcBankIdx
[j
-1];
1472 if (banks_ptr
>= banks_alloc
)
1477 b
= realloc (_fcBankId
, (banks_alloc
+ 4) * sizeof(int));
1482 bidx
= realloc (_fcBankIdx
, (banks_alloc
+ 4) * sizeof(int));
1487 bds
= realloc (bankDirs
, (banks_alloc
+ 4) * sizeof (char *));
1496 _fcBankId
[i
] = bank
;
1502 FcCacheAddBankDir (int bank
, const char * dir
)
1504 int bi
= FcCacheBankToIndexMTF (bank
);
1509 bankDirs
[bi
] = (const char *)FcStrCopy ((FcChar8
*)dir
);
1513 FcCacheFindBankDir (int bank
)
1515 int bi
= FcCacheBankToIndex (bank
);
1516 return bankDirs
[bi
];
1520 * This code implements the MD5 message-digest algorithm.
1521 * The algorithm is due to Ron Rivest. This code was
1522 * written by Colin Plumb in 1993, no copyright is claimed.
1523 * This code is in the public domain; do with it what you wish.
1525 * Equivalent code is available from RSA Data Security, Inc.
1526 * This code has been tested against that, and is equivalent,
1527 * except that you don't need to include two pages of legalese
1530 * To compute the message digest of a chunk of bytes, declare an
1531 * MD5Context structure, pass it to MD5Init, call MD5Update as
1532 * needed on buffers full of bytes, and then call MD5Final, which
1533 * will fill a supplied 16-byte array with the digest.
1537 #define byteReverse(buf, len) /* Nothing */
1540 * Note: this code is harmless on little-endian machines.
1542 void byteReverse(unsigned char *buf
, unsigned longs
)
1546 t
= (FcChar32
) ((unsigned) buf
[3] << 8 | buf
[2]) << 16 |
1547 ((unsigned) buf
[1] << 8 | buf
[0]);
1548 *(FcChar32
*) buf
= t
;
1555 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
1556 * initialization constants.
1558 static void MD5Init(struct MD5Context
*ctx
)
1560 ctx
->buf
[0] = 0x67452301;
1561 ctx
->buf
[1] = 0xefcdab89;
1562 ctx
->buf
[2] = 0x98badcfe;
1563 ctx
->buf
[3] = 0x10325476;
1570 * Update context to reflect the concatenation of another buffer full
1573 static void MD5Update(struct MD5Context
*ctx
, unsigned char *buf
, unsigned len
)
1577 /* Update bitcount */
1580 if ((ctx
->bits
[0] = t
+ ((FcChar32
) len
<< 3)) < t
)
1581 ctx
->bits
[1]++; /* Carry from low to high */
1582 ctx
->bits
[1] += len
>> 29;
1584 t
= (t
>> 3) & 0x3f; /* Bytes already in shsInfo->data */
1586 /* Handle any leading odd-sized chunks */
1589 unsigned char *p
= (unsigned char *) ctx
->in
+ t
;
1593 memcpy(p
, buf
, len
);
1597 byteReverse(ctx
->in
, 16);
1598 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1602 /* Process data in 64-byte chunks */
1605 memcpy(ctx
->in
, buf
, 64);
1606 byteReverse(ctx
->in
, 16);
1607 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1612 /* Handle any remaining bytes of data. */
1614 memcpy(ctx
->in
, buf
, len
);
1618 * Final wrapup - pad to 64-byte boundary with the bit pattern
1619 * 1 0* (64-bit count of bits processed, MSB-first)
1621 static void MD5Final(unsigned char digest
[16], struct MD5Context
*ctx
)
1626 /* Compute number of bytes mod 64 */
1627 count
= (ctx
->bits
[0] >> 3) & 0x3F;
1629 /* Set the first char of padding to 0x80. This is safe since there is
1630 always at least one byte free */
1631 p
= ctx
->in
+ count
;
1634 /* Bytes of padding needed to make 64 bytes */
1635 count
= 64 - 1 - count
;
1637 /* Pad out to 56 mod 64 */
1639 /* Two lots of padding: Pad the first block to 64 bytes */
1640 memset(p
, 0, count
);
1641 byteReverse(ctx
->in
, 16);
1642 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1644 /* Now fill the next block with 56 bytes */
1645 memset(ctx
->in
, 0, 56);
1647 /* Pad block to 56 bytes */
1648 memset(p
, 0, count
- 8);
1650 byteReverse(ctx
->in
, 14);
1652 /* Append length in bits and transform */
1653 ((FcChar32
*) ctx
->in
)[14] = ctx
->bits
[0];
1654 ((FcChar32
*) ctx
->in
)[15] = ctx
->bits
[1];
1656 MD5Transform(ctx
->buf
, (FcChar32
*) ctx
->in
);
1657 byteReverse((unsigned char *) ctx
->buf
, 4);
1658 memcpy(digest
, ctx
->buf
, 16);
1659 memset(ctx
, 0, sizeof(ctx
)); /* In case it's sensitive */
1663 /* The four core functions - F1 is optimized somewhat */
1665 /* #define F1(x, y, z) (x & y | ~x & z) */
1666 #define F1(x, y, z) (z ^ (x & (y ^ z)))
1667 #define F2(x, y, z) F1(z, x, y)
1668 #define F3(x, y, z) (x ^ y ^ z)
1669 #define F4(x, y, z) (y ^ (x | ~z))
1671 /* This is the central step in the MD5 algorithm. */
1672 #define MD5STEP(f, w, x, y, z, data, s) \
1673 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
1676 * The core of the MD5 algorithm, this alters an existing MD5 hash to
1677 * reflect the addition of 16 longwords of new data. MD5Update blocks
1678 * the data and converts bytes into longwords for this routine.
1680 static void MD5Transform(FcChar32 buf
[4], FcChar32 in
[16])
1682 register FcChar32 a
, b
, c
, d
;
1689 MD5STEP(F1
, a
, b
, c
, d
, in
[0] + 0xd76aa478, 7);
1690 MD5STEP(F1
, d
, a
, b
, c
, in
[1] + 0xe8c7b756, 12);
1691 MD5STEP(F1
, c
, d
, a
, b
, in
[2] + 0x242070db, 17);
1692 MD5STEP(F1
, b
, c
, d
, a
, in
[3] + 0xc1bdceee, 22);
1693 MD5STEP(F1
, a
, b
, c
, d
, in
[4] + 0xf57c0faf, 7);
1694 MD5STEP(F1
, d
, a
, b
, c
, in
[5] + 0x4787c62a, 12);
1695 MD5STEP(F1
, c
, d
, a
, b
, in
[6] + 0xa8304613, 17);
1696 MD5STEP(F1
, b
, c
, d
, a
, in
[7] + 0xfd469501, 22);
1697 MD5STEP(F1
, a
, b
, c
, d
, in
[8] + 0x698098d8, 7);
1698 MD5STEP(F1
, d
, a
, b
, c
, in
[9] + 0x8b44f7af, 12);
1699 MD5STEP(F1
, c
, d
, a
, b
, in
[10] + 0xffff5bb1, 17);
1700 MD5STEP(F1
, b
, c
, d
, a
, in
[11] + 0x895cd7be, 22);
1701 MD5STEP(F1
, a
, b
, c
, d
, in
[12] + 0x6b901122, 7);
1702 MD5STEP(F1
, d
, a
, b
, c
, in
[13] + 0xfd987193, 12);
1703 MD5STEP(F1
, c
, d
, a
, b
, in
[14] + 0xa679438e, 17);
1704 MD5STEP(F1
, b
, c
, d
, a
, in
[15] + 0x49b40821, 22);
1706 MD5STEP(F2
, a
, b
, c
, d
, in
[1] + 0xf61e2562, 5);
1707 MD5STEP(F2
, d
, a
, b
, c
, in
[6] + 0xc040b340, 9);
1708 MD5STEP(F2
, c
, d
, a
, b
, in
[11] + 0x265e5a51, 14);
1709 MD5STEP(F2
, b
, c
, d
, a
, in
[0] + 0xe9b6c7aa, 20);
1710 MD5STEP(F2
, a
, b
, c
, d
, in
[5] + 0xd62f105d, 5);
1711 MD5STEP(F2
, d
, a
, b
, c
, in
[10] + 0x02441453, 9);
1712 MD5STEP(F2
, c
, d
, a
, b
, in
[15] + 0xd8a1e681, 14);
1713 MD5STEP(F2
, b
, c
, d
, a
, in
[4] + 0xe7d3fbc8, 20);
1714 MD5STEP(F2
, a
, b
, c
, d
, in
[9] + 0x21e1cde6, 5);
1715 MD5STEP(F2
, d
, a
, b
, c
, in
[14] + 0xc33707d6, 9);
1716 MD5STEP(F2
, c
, d
, a
, b
, in
[3] + 0xf4d50d87, 14);
1717 MD5STEP(F2
, b
, c
, d
, a
, in
[8] + 0x455a14ed, 20);
1718 MD5STEP(F2
, a
, b
, c
, d
, in
[13] + 0xa9e3e905, 5);
1719 MD5STEP(F2
, d
, a
, b
, c
, in
[2] + 0xfcefa3f8, 9);
1720 MD5STEP(F2
, c
, d
, a
, b
, in
[7] + 0x676f02d9, 14);
1721 MD5STEP(F2
, b
, c
, d
, a
, in
[12] + 0x8d2a4c8a, 20);
1723 MD5STEP(F3
, a
, b
, c
, d
, in
[5] + 0xfffa3942, 4);
1724 MD5STEP(F3
, d
, a
, b
, c
, in
[8] + 0x8771f681, 11);
1725 MD5STEP(F3
, c
, d
, a
, b
, in
[11] + 0x6d9d6122, 16);
1726 MD5STEP(F3
, b
, c
, d
, a
, in
[14] + 0xfde5380c, 23);
1727 MD5STEP(F3
, a
, b
, c
, d
, in
[1] + 0xa4beea44, 4);
1728 MD5STEP(F3
, d
, a
, b
, c
, in
[4] + 0x4bdecfa9, 11);
1729 MD5STEP(F3
, c
, d
, a
, b
, in
[7] + 0xf6bb4b60, 16);
1730 MD5STEP(F3
, b
, c
, d
, a
, in
[10] + 0xbebfbc70, 23);
1731 MD5STEP(F3
, a
, b
, c
, d
, in
[13] + 0x289b7ec6, 4);
1732 MD5STEP(F3
, d
, a
, b
, c
, in
[0] + 0xeaa127fa, 11);
1733 MD5STEP(F3
, c
, d
, a
, b
, in
[3] + 0xd4ef3085, 16);
1734 MD5STEP(F3
, b
, c
, d
, a
, in
[6] + 0x04881d05, 23);
1735 MD5STEP(F3
, a
, b
, c
, d
, in
[9] + 0xd9d4d039, 4);
1736 MD5STEP(F3
, d
, a
, b
, c
, in
[12] + 0xe6db99e5, 11);
1737 MD5STEP(F3
, c
, d
, a
, b
, in
[15] + 0x1fa27cf8, 16);
1738 MD5STEP(F3
, b
, c
, d
, a
, in
[2] + 0xc4ac5665, 23);
1740 MD5STEP(F4
, a
, b
, c
, d
, in
[0] + 0xf4292244, 6);
1741 MD5STEP(F4
, d
, a
, b
, c
, in
[7] + 0x432aff97, 10);
1742 MD5STEP(F4
, c
, d
, a
, b
, in
[14] + 0xab9423a7, 15);
1743 MD5STEP(F4
, b
, c
, d
, a
, in
[5] + 0xfc93a039, 21);
1744 MD5STEP(F4
, a
, b
, c
, d
, in
[12] + 0x655b59c3, 6);
1745 MD5STEP(F4
, d
, a
, b
, c
, in
[3] + 0x8f0ccc92, 10);
1746 MD5STEP(F4
, c
, d
, a
, b
, in
[10] + 0xffeff47d, 15);
1747 MD5STEP(F4
, b
, c
, d
, a
, in
[1] + 0x85845dd1, 21);
1748 MD5STEP(F4
, a
, b
, c
, d
, in
[8] + 0x6fa87e4f, 6);
1749 MD5STEP(F4
, d
, a
, b
, c
, in
[15] + 0xfe2ce6e0, 10);
1750 MD5STEP(F4
, c
, d
, a
, b
, in
[6] + 0xa3014314, 15);
1751 MD5STEP(F4
, b
, c
, d
, a
, in
[13] + 0x4e0811a1, 21);
1752 MD5STEP(F4
, a
, b
, c
, d
, in
[4] + 0xf7537e82, 6);
1753 MD5STEP(F4
, d
, a
, b
, c
, in
[11] + 0xbd3af235, 10);
1754 MD5STEP(F4
, c
, d
, a
, b
, in
[2] + 0x2ad7d2bb, 15);
1755 MD5STEP(F4
, b
, c
, d
, a
, in
[9] + 0xeb86d391, 21);