?? ardirout.c
字號:
/*
Copyright (c) 2003, Dan Kranz and Arnold Rom
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
* The names of its contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <roots.h>
/* ############################################################################# */
/* BYTE FormatAndWriteDirectory(Database* db) # */
/* # */
/* return 0 if directory was read and translated. # */
/* return 1 otherwise. # */
/* # */
/* input: db structure will be initialized based on the directory values # */
/* # */
/* ############################################################################# */
BYTE FormatAndWriteDirectory(DataBase* db)
/* ---------------------------------------------------------------------------- */
{ /* FormatAndWriteDirectory START */
/* ---------------------------------------------------------------------------- */
/* local data */
BlockCplNline buf;
static long n1=1;
char fspec[MAX_PATH];
/* ++ T&& &&&&&&&&&&&& 0000 */
static long byteWidth[2]={1,-2},fType=4,tnum[2]={5,-2},
label[2]={8,MAXLAB-1},display[2]={8+MAXLAB,-4};
BYTE* kout;
long kt,nameStart=0,nameEnd=0,bfi,line,value,v[2];
/* define blank field output block to hold the directory */
memset(&buf,'\0',sizeof(buf));
buf.cpl=60; buf.nline=db->nfields+1;
ExpandBlock(buf,buf.nline);
memset(buf.block,' ',buf.cpl*buf.nline);
/* search for base name without path */
for(kt=0; db->name[kt] != '\0' && kt<MAX_PATH; kt++)
{
if(db->name[kt] == '\\' || db->name[kt] == '/') nameStart=kt+1;
else nameEnd=kt;
}
if(nameStart>nameEnd)
{RootsError("unable to extract data base name from: %s\n",
db->name); return 1;}
/* store data base name on first directory line */
strncpy(buf.block,&db->name[nameStart],nameEnd-nameStart+1);
/* ------------------------------------------------------------------------- */
/* convert all fields */
/* ------------------------------------------------------------------------- */
for(bfi=0,line=2; bfi<db->nfields; bfi++,line++)
{
kout=BlockPointer(buf,line);
/* convert field width */
value=db->blkfld[bfi][1];
chcbd(&value,kout,byteWidth,&n1);
/* convert label, display width and type field */
value=db->dspcpl[bfi];
chcbd(&value,kout,display,&n1);
v[0]=1; v[1]=db->labcpl[bfi];
chmove(db->label[bfi],v,kout,label,&n1);
switch(db->ARMRtype[bfi])
/* ------------------------------- */
{ /* switch start */
/* ------------------------------- */
/* --------- */
case B_TYPE:
/* --------- */
*(kout+fType-1)='B';
break;
/* --------- */
case R_TYPE:
/* --------- */
*(kout+fType-1)='R';
if(db->dspdec[bfi]!=0)
{
value=db->dspdec[bfi]; /* implement later a switch for */
chcbd(&value,kout,tnum,&n1); /* old style directory!! */
}
break;
/* --------- */
case T_TYPE:
/* --------- */
*(kout+fType-1)='T';
value=db->tabinx[bfi];
chcbd(&value,kout,tnum,&n1);
break;
/* --------- */
case E_TYPE:
/* --------- */
*(kout+fType-1)='E';
break;
/* --------- */
case D_TYPE:
/* --------- */
*(kout+fType-1)='D'; /* implement later a switch for */
/* old style directory!! */
break;
/* --------- */
case Z_TYPE:
/* --------- */
*(kout+fType-1)='Z'; /* implement later a switch for */
/* old style directory!! */
break;
/* --------- */
default:
/* --------- */
RootsError("directory sos\n"); return 1;
/* ------------------------------- */
} /* switch end */
/* ------------------------------- */
}
/* -------------------------------------------------------------------------- */
/* crunch and write the directory */
/* -------------------------------------------------------------------------- */
if(WriteRectangle(&buf,strcat(strcpy(fspec,db->name),".dir")))return 1;
FreeBlock(buf);
return 0;
/* ---------------------------------------------------------------------------- */
} /* FormatAndWriteDirectory END */
/* ---------------------------------------------------------------------------- */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -