void FcitxXkbOptionInfoCopy(void* dst, const void* src) { FcitxXkbOptionInfo* optionInfoDst = (FcitxXkbOptionInfo*) dst; FcitxXkbOptionInfo* optionInfoSrc = (FcitxXkbOptionInfo*) src; optionInfoDst->name = COPY_IF_NOT_NULL(optionInfoSrc->name); optionInfoDst->description = COPY_IF_NOT_NULL(optionInfoSrc->description); }
void FcitxXkbVariantInfoCopy(void* dst, const void* src) { FcitxXkbVariantInfo* variantInfoDst = (FcitxXkbVariantInfo*) dst; FcitxXkbVariantInfo* variantInfoSrc = (FcitxXkbVariantInfo*) src; variantInfoDst->name = COPY_IF_NOT_NULL(variantInfoSrc->name); variantInfoDst->description = COPY_IF_NOT_NULL(variantInfoSrc->description); variantInfoDst->languages = utarray_clone(variantInfoSrc->languages); }
void FcitxXkbModelInfoCopy(void* dst, const void* src) { FcitxXkbModelInfo* modeInfoDst = (FcitxXkbModelInfo*) dst; FcitxXkbModelInfo* modeInfoSrc = (FcitxXkbModelInfo*) src; modeInfoDst->name = COPY_IF_NOT_NULL(modeInfoSrc->name); modeInfoDst->description = COPY_IF_NOT_NULL(modeInfoSrc->description); modeInfoDst->vendor = COPY_IF_NOT_NULL(modeInfoSrc->vendor); }
void FcitxXkbOptionGroupInfoCopy(void* dst, const void* src) { FcitxXkbOptionGroupInfo* optionGroupInfoDst = (FcitxXkbOptionGroupInfo*) dst; FcitxXkbOptionGroupInfo* optionGroupInfoSrc = (FcitxXkbOptionGroupInfo*) src; optionGroupInfoDst->name = COPY_IF_NOT_NULL(optionGroupInfoSrc->name); optionGroupInfoDst->description = COPY_IF_NOT_NULL(optionGroupInfoSrc->description); optionGroupInfoDst->exclusive = optionGroupInfoSrc->exclusive; optionGroupInfoDst->optionInfos = utarray_clone(optionGroupInfoSrc->optionInfos); }
ST_FUNC ST_Error ST_ID3v1_writeToFile(const ST_ID3v1 *t, const char *fn) { FILE *fp; struct ID3v1_Tag tag; ST_Error rv = ST_Error_None; /* Verify the tag and filename are not NULL */ if(!t || !fn || t->base.type != ST_TagType_ID3v1) return ST_Error_InvalidArgument; /* Open up the file for reading and writing. */ fp = fopen(fn, "r+b"); if(!fp) { rv = ST_Error_errno; goto out; } /* Go to the position where the ID3v1 should be in the file. */ if(fseek(fp, -128, SEEK_END)) { rv = ST_Error_errno; goto out_close; } memset(&tag, 0, sizeof(tag)); /* Read in what should be the magic header, if its there */ if(fread(tag.magic, 1, 3, fp) != 3) { rv = ST_Error_errno; goto out_close; } if(tag.magic[0] != 'T' || tag.magic[1] != 'A' || tag.magic[2] != 'G') { /* No magic value, so we assume the tag isn't actually present. */ if(fseek(fp, 0, SEEK_END)) { rv = ST_Error_errno; goto out_close; } tag.magic[0] = 'T'; tag.magic[1] = 'A'; tag.magic[2] = 'G'; } else { /* We have a tag, reposition to the end so we overwrite the old tag. */ if(fseek(fp, -128, SEEK_END)) { rv = ST_Error_errno; goto out_close; } } /* Fill in the tag. */ COPY_IF_NOT_NULL(tag.title, t->title, 30); COPY_IF_NOT_NULL(tag.artist, t->artist, 30); COPY_IF_NOT_NULL(tag.album, t->album, 30); COPY_IF_NOT_NULL(tag.comment_field.comment, t->comment, 30); COPY_IF_NOT_NULL(tag.year, t->year, 4); tag.genre = t->genre; /* Fill in the track if we have one */ if(t->track) { tag.comment_field.v1_1.zero = 0; tag.comment_field.v1_1.track = t->track; } /* Write it out to the file... */ if(fwrite(&tag, 1, 128, fp) != 128) { rv = ST_Error_errno; goto out_close; } out_close: fclose(fp); out: return rv; }