⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 record.c

📁 创建一个符合iso-9660标准的iso文件系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * hfsutils - tools for reading and writing Macintosh HFS volumes * Copyright (C) 1996, 1997 Robert Leslie * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include <mconfig.h>#include <stdxlib.h>#include <strdefs.h>#include <errno.h>#include "internal.h"#include "data.h"#include "record.h"/* * NAME:	record->packcatkey() * DESCRIPTION:	pack a catalog record key */void r_packcatkey(key, pkey, len)	CatKeyRec	*key;	unsigned char	*pkey;	int		*len;{  unsigned char *start = pkey;  d_storeb(&pkey, key->ckrKeyLen);  d_storeb(&pkey, key->ckrResrv1);  d_storel(&pkey, key->ckrParID);  d_stores(&pkey, key->ckrCName, sizeof(key->ckrCName));  if (len)    *len = HFS_RECKEYSKIP(start);}/* * NAME:	record->unpackcatkey() * DESCRIPTION:	unpack a catalog record key */void r_unpackcatkey(pkey, key)	unsigned char	*pkey;	CatKeyRec	*key;{  d_fetchb(&pkey, (char *) &key->ckrKeyLen);  d_fetchb(&pkey, (char *) &key->ckrResrv1);  d_fetchl(&pkey, (long *) &key->ckrParID);  d_fetchs(&pkey, key->ckrCName, sizeof(key->ckrCName));}/* * NAME:	record->packextkey() * DESCRIPTION:	pack an extents record key */void r_packextkey(key, pkey, len)	ExtKeyRec	*key;	unsigned char	*pkey;	int		*len;{  unsigned char *start = pkey;  d_storeb(&pkey, key->xkrKeyLen);  d_storeb(&pkey, key->xkrFkType);  d_storel(&pkey, key->xkrFNum);  d_storew(&pkey, key->xkrFABN);  if (len)    *len = HFS_RECKEYSKIP(start);}/* * NAME:	record->unpackextkey() * DESCRIPTION:	unpack an extents record key */void r_unpackextkey(pkey, key)	unsigned char	*pkey;	ExtKeyRec	*key;{  d_fetchb(&pkey, (char *) &key->xkrKeyLen);  d_fetchb(&pkey, (char *) &key->xkrFkType);  d_fetchl(&pkey, (long *) &key->xkrFNum);  d_fetchw(&pkey, (short *) &key->xkrFABN);}/* * NAME:	record->comparecatkeys() * DESCRIPTION:	compare two (packed) catalog record keys */int r_comparecatkeys(pkey1, pkey2)	unsigned char	*pkey1;	unsigned char	*pkey2;{  CatKeyRec key1;  CatKeyRec key2;  int diff;  r_unpackcatkey(pkey1, &key1);  r_unpackcatkey(pkey2, &key2);  diff = key1.ckrParID - key2.ckrParID;  if (diff)    return diff;  return d_relstring(key1.ckrCName, key2.ckrCName);}/* * NAME:	record->compareextkeys() * DESCRIPTION:	compare two (packed) extents record keys */int r_compareextkeys(pkey1, pkey2)	unsigned char	*pkey1;	unsigned char	*pkey2;{  ExtKeyRec key1;  ExtKeyRec key2;  int diff;  r_unpackextkey(pkey1, &key1);  r_unpackextkey(pkey2, &key2);  diff = key1.xkrFNum - key2.xkrFNum;  if (diff)    return diff;  diff = (unsigned char) key1.xkrFkType -         (unsigned char) key2.xkrFkType;  if (diff)    return diff;  return key1.xkrFABN - key2.xkrFABN;}/* * NAME:	record->packcatdata() * DESCRIPTION:	pack catalog record data */void r_packcatdata(data, pdata, len)	CatDataRec	*data;	unsigned char	*pdata;	int		*len;{  unsigned char *start = pdata;  int i;  d_storeb(&pdata, data->cdrType);  d_storeb(&pdata, data->cdrResrv2);  switch (data->cdrType)    {    case cdrDirRec:      d_storew(&pdata, data->u.dir.dirFlags);      d_storew(&pdata, data->u.dir.dirVal);      d_storel(&pdata, data->u.dir.dirDirID);      d_storel(&pdata, data->u.dir.dirCrDat);      d_storel(&pdata, data->u.dir.dirMdDat);      d_storel(&pdata, data->u.dir.dirBkDat);      d_storew(&pdata, data->u.dir.dirUsrInfo.frRect.top);      d_storew(&pdata, data->u.dir.dirUsrInfo.frRect.left);      d_storew(&pdata, data->u.dir.dirUsrInfo.frRect.bottom);      d_storew(&pdata, data->u.dir.dirUsrInfo.frRect.right);      d_storew(&pdata, data->u.dir.dirUsrInfo.frFlags);      d_storew(&pdata, data->u.dir.dirUsrInfo.frLocation.v);      d_storew(&pdata, data->u.dir.dirUsrInfo.frLocation.h);      d_storew(&pdata, data->u.dir.dirUsrInfo.frView);      d_storew(&pdata, data->u.dir.dirFndrInfo.frScroll.v);      d_storew(&pdata, data->u.dir.dirFndrInfo.frScroll.h);      d_storel(&pdata, data->u.dir.dirFndrInfo.frOpenChain);      d_storew(&pdata, data->u.dir.dirFndrInfo.frUnused);      d_storew(&pdata, data->u.dir.dirFndrInfo.frComment);      d_storel(&pdata, data->u.dir.dirFndrInfo.frPutAway);      for (i = 0; i < 4; ++i)	d_storel(&pdata, data->u.dir.dirResrv[i]);      break;    case cdrFilRec:      d_storeb(&pdata, data->u.fil.filFlags);      d_storeb(&pdata, data->u.fil.filTyp);      d_storel(&pdata, data->u.fil.filUsrWds.fdType);      d_storel(&pdata, data->u.fil.filUsrWds.fdCreator);      d_storew(&pdata, data->u.fil.filUsrWds.fdFlags);      d_storew(&pdata, data->u.fil.filUsrWds.fdLocation.v);      d_storew(&pdata, data->u.fil.filUsrWds.fdLocation.h);      d_storew(&pdata, data->u.fil.filUsrWds.fdFldr);      d_storel(&pdata, data->u.fil.filFlNum);      d_storew(&pdata, data->u.fil.filStBlk);      d_storel(&pdata, data->u.fil.filLgLen);      d_storel(&pdata, data->u.fil.filPyLen);      d_storew(&pdata, data->u.fil.filRStBlk);      d_storel(&pdata, data->u.fil.filRLgLen);      d_storel(&pdata, data->u.fil.filRPyLen);      d_storel(&pdata, data->u.fil.filCrDat);      d_storel(&pdata, data->u.fil.filMdDat);      d_storel(&pdata, data->u.fil.filBkDat);      d_storew(&pdata, data->u.fil.filFndrInfo.fdIconID);      for (i = 0; i < 4; ++i)	d_storew(&pdata, data->u.fil.filFndrInfo.fdUnused[i]);      d_storew(&pdata, data->u.fil.filFndrInfo.fdComment);      d_storel(&pdata, data->u.fil.filFndrInfo.fdPutAway);      d_storew(&pdata, data->u.fil.filClpSize);      for (i = 0; i < 3; ++i)	{	  d_storew(&pdata, data->u.fil.filExtRec[i].xdrStABN);	  d_storew(&pdata, data->u.fil.filExtRec[i].xdrNumABlks);	}      for (i = 0; i < 3; ++i)	{	  d_storew(&pdata, data->u.fil.filRExtRec[i].xdrStABN);	  d_storew(&pdata, data->u.fil.filRExtRec[i].xdrNumABlks);	}      d_storel(&pdata, data->u.fil.filResrv);      break;    case cdrThdRec:      for (i = 0; i < 2; ++i)	d_storel(&pdata, data->u.dthd.thdResrv[i]);      d_storel(&pdata, data->u.dthd.thdParID);      d_stores(&pdata, data->u.dthd.thdCName, sizeof(data->u.dthd.thdCName));      break;    case cdrFThdRec:      for (i = 0; i < 2; ++i)	d_storel(&pdata, data->u.fthd.fthdResrv[i]);      d_storel(&pdata, data->u.fthd.fthdParID);      d_stores(&pdata, data->u.fthd.fthdCName, sizeof(data->u.fthd.fthdCName));      break;    default:      abort();    }  if (len)    *len += pdata - start;}/* * NAME:	record->unpackcatdata() * DESCRIPTION:	unpack catalog record data */void r_unpackcatdata(pdata, data)	unsigned char	*pdata;	CatDataRec	*data;{  int i;  d_fetchb(&pdata, (char *) &data->cdrType);  d_fetchb(&pdata, (char *) &data->cdrResrv2);  switch (data->cdrType)    {    case cdrDirRec:      d_fetchw(&pdata, &data->u.dir.dirFlags);      d_fetchw(&pdata, (short *) &data->u.dir.dirVal);      d_fetchl(&pdata, (long *) &data->u.dir.dirDirID);      d_fetchl(&pdata, &data->u.dir.dirCrDat);      d_fetchl(&pdata, &data->u.dir.dirMdDat);      d_fetchl(&pdata, &data->u.dir.dirBkDat);      d_fetchw(&pdata, &data->u.dir.dirUsrInfo.frRect.top);      d_fetchw(&pdata, &data->u.dir.dirUsrInfo.frRect.left);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -