/*给定的mdpath 表示目的文件的绝对路径名,如果没有指定合适的目的路径或者mdpath所指的文件不存在,则写入错误信息并返回-1*/
int write_to_and_from_qvfb_mutex(const char *mdpath, const void *toput, PIC_LENGTH_T putlen, void *toget, PIC_LENGTH_T *getlen)
{
int writekey;
int readkey;
void *shmp;
int ret;
if (mdpath == NULL || toput == NULL || putlen <= 0 || toget == NULL || getlen == NULL)
{
fprintf(stderr, "[%s] mdpath is NULL\n", __FUNCTION__);
return -1;
}
do
{
if ((writekey = open_shmem(mdpath, &shmp, O_WRONLY | O_CREAT, QVFB_SHM_PERM)) < 0)
{
fprintf(stderr, "[%s] open_shmem failed to get write key\n", __FUNCTION__);
ret = -1;
break;
}
if ((readkey = open_shmem(mdpath, &shmp, O_RDONLY, QVFB_SHM_PERM)) < 0)
{
fprintf(stderr, "[%s] open_shmem failed to get read key\n", __FUNCTION__);
ret = -1;
break;
}
if ((ret = lm_flush_md($mdpath, shmp, toput, putlen)) < 0)
{
ret = -1;
break;
}
if ((ret = lm_image_get($mdpath, shmp, toget, getlen)) < 0)
{
ret = -1;
}
close_shmem(mdpath, shmp, writekey, writekey);
close_shmem(mdpath, shmp, readkey, readkey);
} while (0);
return ret;
}
#endif // #ifdef HAVE_LIBJPEG