Lines Matching refs:fp
367 static int metadata_add(FILE *fp, long start, const char *tag,
370 if (fseek(fp, start, SEEK_SET) < 0 ||
371 fprintf(fp, "%s %u\n", tag, length) < 0) {
375 *offset = ftell(fp);
377 if (fseek(fp, length, SEEK_CUR) < 0 ||
378 fprintf(fp, METADATA_EOD " 0\n") < 0) {
388 FILE *fp = NULL;
400 fp = fopen(fname, "r+");
402 if (!fp) {
408 if (fseek(fp, start, SEEK_SET) < 0 ||
409 fread(&magic, sizeof(magic), 1, fp) != 1) {
417 if (fseek(fp, start, SEEK_SET) < 0 ||
418 fwrite(&magic, sizeof(magic), 1, fp) != 1) {
423 rc = metadata_add(fp, start + sizeof(magic), stag, slength, offset);
434 n = fscanf(fp, "%" STRINGIFY(METADATA_TAG_MAX_LENGTH) "s %u\n",
439 start = ftell(fp);
449 if (fseek(fp, length, SEEK_CUR) < 0) {
454 rc = metadata_add(fp, start, stag, slength, offset);
463 if (fp) {
464 fflush(fp);
465 fclose(fp);