Lines Matching refs:fp

418 #define	READ_TOKEN_INFO_STR(fp, rec, reclen) rc = fread(rec, reclen, 1, fp); \
421 #define READ_TOKEN_INFO_UINT32(fp, rec) rc = fread(&fieldval, \
422 sizeof (UINT32), 1, fp); \
429 FILE *fp;
445 fp = fopen((char *)fname, "r");
446 if (!fp) {
464 fp = fopen((char *)fname, "r");
465 if (!fp) {
477 if (lockfile(fileno(fp), F_RDLCK)) {
478 (void) fclose(fp);
482 set_perm(fileno(fp));
485 READ_TOKEN_INFO_STR(fp, td->token_info.label,
487 READ_TOKEN_INFO_STR(fp, td->token_info.manufacturerID,
489 READ_TOKEN_INFO_STR(fp, td->token_info.model,
491 READ_TOKEN_INFO_STR(fp, td->token_info.serialNumber,
493 READ_TOKEN_INFO_UINT32(fp, td->token_info.flags);
494 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulMaxSessionCount);
495 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulSessionCount);
496 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulRwSessionCount);
497 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulMaxPinLen);
498 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulMinPinLen);
499 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulTotalPublicMemory);
500 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulFreePublicMemory);
501 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulTotalPrivateMemory);
502 READ_TOKEN_INFO_UINT32(fp, td->token_info.ulFreePrivateMemory);
503 READ_TOKEN_INFO_STR(fp, &td->token_info.hardwareVersion,
505 READ_TOKEN_INFO_STR(fp, &td->token_info.firmwareVersion,
507 READ_TOKEN_INFO_STR(fp, td->token_info.utcTime,
509 READ_TOKEN_INFO_STR(fp, td->user_pin_sha,
511 READ_TOKEN_INFO_STR(fp, td->so_pin_sha,
513 READ_TOKEN_INFO_STR(fp, td->next_token_object_name,
515 READ_TOKEN_INFO_STR(fp, &td->tweak_vector,
518 (void) lockfile(fileno(fp), F_UNLCK);
519 (void) fclose(fp);
534 #define WRITE_TOKEN_INFO_STR(fp, rec, reclen) rc = fwrite(rec, reclen, 1, fp); \
537 #define WRITE_TOKEN_INFO_UINT32(fp, rec) fieldval = (UINT32)rec; \
538 rc = fwrite(&fieldval, sizeof (UINT32), 1, fp); \
544 FILE *fp;
560 fp = fopen((char *)fname, "w");
562 if (!fp) {
566 if (lockfile(fileno(fp), F_WRLCK)) {
568 (void) fclose(fp);
571 set_perm(fileno(fp));
574 WRITE_TOKEN_INFO_STR(fp, td->token_info.label,
576 WRITE_TOKEN_INFO_STR(fp, td->token_info.manufacturerID,
578 WRITE_TOKEN_INFO_STR(fp, td->token_info.model,
580 WRITE_TOKEN_INFO_STR(fp, td->token_info.serialNumber,
582 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.flags);
583 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulMaxSessionCount);
584 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulSessionCount);
585 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulRwSessionCount);
586 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulMaxPinLen);
587 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulMinPinLen);
588 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulTotalPublicMemory);
589 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulFreePublicMemory);
590 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulTotalPrivateMemory);
591 WRITE_TOKEN_INFO_UINT32(fp, td->token_info.ulFreePrivateMemory);
592 WRITE_TOKEN_INFO_STR(fp, &td->token_info.hardwareVersion,
594 WRITE_TOKEN_INFO_STR(fp, &td->token_info.firmwareVersion,
596 WRITE_TOKEN_INFO_STR(fp, td->token_info.utcTime,
598 WRITE_TOKEN_INFO_STR(fp, td->user_pin_sha,
600 WRITE_TOKEN_INFO_STR(fp, td->so_pin_sha,
602 WRITE_TOKEN_INFO_STR(fp, td->next_token_object_name,
604 WRITE_TOKEN_INFO_STR(fp, &td->tweak_vector,
607 (void) lockfile(fileno(fp), F_UNLCK);
608 (void) fclose(fp);
621 FILE *fp = NULL;
641 fp = fopen((char *)fname, "r");
642 if (fp) {
643 if (lockfile(fileno(fp), F_RDLCK)) {
644 (void) fclose(fp);
647 set_perm(fileno(fp));
648 while (!feof(fp)) {
649 (void) fgets((char *)line, 50, fp);
650 if (!feof(fp)) {
654 (void) lockfile(fileno(fp), F_UNLCK);
655 (void) fclose(fp);
660 (void) lockfile(fileno(fp), F_UNLCK);
661 (void) fclose(fp);
664 fp = fopen((char *)fname, "a");
665 if (!fp)
668 if (lockfile(fileno(fp), F_WRLCK)) {
669 (void) fclose(fp);
672 set_perm(fileno(fp));
674 (void) fprintf(fp, "%s\n", obj->name);
675 (void) lockfile(fileno(fp), F_UNLCK);
676 (void) fclose(fp);
684 FILE *fp = NULL;
704 fp = fopen((char *)fname, "w");
705 if (!fp) {
711 if (lockfile(fileno(fp), F_WRLCK)) {
712 (void) fclose(fp);
716 set_perm(fileno(fp));
720 (void) fwrite(&total_len, sizeof (total_len), 1, fp);
721 (void) fwrite(&flag, sizeof (flag), 1, fp);
722 (void) fwrite(cleartxt, cleartxt_len, 1, fp);
724 (void) lockfile(fileno(fp), F_UNLCK);
725 (void) fclose(fp);
731 if (fp)
732 (void) fclose(fp);
741 FILE *fp = NULL;
820 fp = fopen((char *)fname, "w");
821 if (!fp) {
825 if (lockfile(fileno(fp), F_WRLCK)) {
830 set_perm(fileno(fp));
836 (void) fwrite(&total_len, sizeof (UINT32), 1, fp);
837 (void) fwrite(&flag, sizeof (CK_BBOOL), 1, fp);
838 (void) fwrite(ciphertxt, ciphertxt_len, 1, fp);
840 (void) lockfile(fileno(fp), F_UNLCK);
841 (void) fclose(fp);
849 if (fp)
850 (void) fclose(fp);
1106 FILE *fp = NULL;
1124 fp = fopen((char *)fname, "r");
1125 if (!fp) {
1129 if (lockfile(fileno(fp), F_RDLCK)) {
1134 set_perm(fileno(fp));
1136 (void) fread(&size, sizeof (UINT32), 1, fp);
1137 (void) fread(&priv, sizeof (CK_BBOOL), 1, fp);
1147 (void) fread(buf, size, 1, fp);
1156 if (fp) {
1157 (void) lockfile(fileno(fp), F_UNLCK);
1158 (void) fclose(fp);