亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tarlib.c

?? vxworks的完整的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* tarLib.c - UNIX tar compatible library *//* Copyright 1993-2002 Wind River Systems, Inc. *//* Copyright (c) 1993, 1994 RST Software Industries Ltd. *//*modification history--------------------01i,20sep01,jkf  SPR#69031, common code for both AE & 5.x.01h,26dec99,jkf  T3 KHEAP_ALLOC03g,11nov99,jkf  need to fill all eight bytes with 0x20 for the checksum                  calc correct for MKS toolkit 6.2 generated tar file.03f,31jul99,jkf  T2 merge, tidiness & spelling.03e,30jul98,lrn  partial doc cleanup03b,24jun98,lrn  fixed bug causing 0-size files to be extracted as dirs,		 improved tarHelp to list parameters03a,07jun98,lrn  derived from RST usrTapeLib.c, cleaned all tape related stuff02f,15jan95,rst  adding TarToc functionality02d,28mar94,rst  added Tar utilities.*//*DESCRIPTIONThis library implements functions for archiving, extracting and listingof UNIX-compatible "tar" file archives.It can be used to archive and extract entire file hierarchiesto/from archive files on local or remote disks, or directly to/frommagnetic tapes.SEE ALSO: dosFsLibCURRENT LIMITATIONSThis Tar utility does not handle MS-DOS file attributes,when used in conjunction with the MS-DOS file system.The maximum subdirectory depth supported by this library is 16,while the total maximum path name that can be handled by tar is limited at 100 characters.*/#include "vxWorks.h"#include "stdlib.h"#include "ioLib.h"#include "errnoLib.h"#include "string.h"#include "stdio.h"#include "private/dosFsVerP.h"#include "dosFsLib.h"#include "dirent.h"#include "stat.h"#include "tarLib.h"/* data types *//* * VxWorks Tar Utility, part of usrTapeLib (for now). * UNIX tar(1) tape format - header definition */#define TBLOCK		512	/* TAR Tape block size, part of TAR format */#define NAMSIZ		100	/* size of file name in TAR tape header */#define	MAXLEVEL	16	/* max. # of subdirectory levels, arbitrary */#define	NULLDEV		"/null"	/* data sink */typedef union hblock    {    char dummy[TBLOCK];    struct header	{	char name[NAMSIZ];	char mode[8];	char uid[8];	char gid[8];	char size[12];	char mtime[12];	char chksum[8];	char linkflag;	char linkname[NAMSIZ];    	}    dbuf;    } MT_HBLOCK ;/* Control structure used internally for reentrancy etc. */typedef struct    {    int 	fd ;			/* current tape file descriptor */    int		bFactor;		/* current blocking factor */    int		bValid;			/* number of valid blocks in buffer */    int		recurseCnt;		/* recusrion counter */    MT_HBLOCK *	pBuf;			/* working buffer */    MT_HBLOCK *	pBnext;			/* ptr to next block to return */    } MT_TAR_SOFT ;/* globals */char *TAPE = "/archive0.tar" ;	/* default archive name *//* locals */LOCAL char	bZero[ TBLOCK ] ; /* zeroed block *//********************************************************************************* tarHelp - print help information about TAR archive functions.** NOMANUAL*/void tarHelp    (    void    )    {    int i ;    const char * help_msg[] = {    "Help information on TAR archival functions:\n",    "\n",    " Archive any directory: \n",    "    tarArchive( archFile, bfactor, verbose, dirName )\n",    " Extract from TAR archive into current directory:\n",    "    tarExtract( archFile, bfactor, verbose )\n",    " List contents of TAR archive\n",    "    tarToc( archFile, bfactor)\n",    "      if <dirName> is NULL, archive current directory\n",    "\n", NULL     };    for(i = 0; help_msg[i] != NULL ; i++ )	printf(help_msg[i]);    printf(" if <archFile> is NULL,\n"	"current default archive file \"%s\" will be used,\n", TAPE);    printf(" change the TAPE variable to set a different name.\n\n");    }/********************************************************************************* mtChecksum - calculate checksums for tar header blocks** RETURNS: the checksum value*/LOCAL int mtChecksum    (    void *	pBuf,    unsigned	size    )    {    register int sum = 0 ;    register unsigned char *p = pBuf ;    while( size > 0 )	{	sum += *p++;	size -= sizeof(*p);	}    return(sum);    }/********************************************************************************* tarRdBlks - read <nBlocks> blocks from tape** RETURNS: number of blocks actually got, or ERROR.*/LOCAL int tarRdBlks    (    MT_TAR_SOFT *pCtrl,		/* control structure */    MT_HBLOCK **ppBlk,		/* where to return buffer address */    unsigned int nBlocks	/* how many blocks to get */    )    {    register int rc ;    if (pCtrl->bValid <= 0)	{	/* buffer empty, read more blocks from tape */	rc = read(pCtrl->fd, pCtrl->pBuf->dummy, pCtrl->bFactor * TBLOCK);	if ( rc == ERROR )	    return ERROR ;	else if( rc == 0 )	    return 0 ;	else if( (rc % TBLOCK) != 0 )	    {	    printErr("tarRdBlks: tape block not multiple of %d\n", TBLOCK);	    return ERROR;	    }		pCtrl->bValid = rc / TBLOCK ;	pCtrl->pBnext = pCtrl->pBuf ;	}    rc = min((ULONG)pCtrl->bValid, nBlocks) ;    *ppBlk = pCtrl->pBnext ;    pCtrl->bValid -= rc ;    pCtrl->pBnext += rc ;    return( rc ) ;    }/********************************************************************************* mtAccess - check existence of path for a new file or directory <name>** RETURNS: OK or ERROR*/LOCAL STATUS mtAccess    (    const char *name    )    {    char tmpName [ NAMSIZ ] ;    struct stat st ;    int i ;    static char slash = '/' ;    register char *pSlash ;    strncpy( tmpName, name, NAMSIZ ) ;    pSlash = tmpName ;    for(i=0; i<MAXLEVEL; i++)	{	if ( (pSlash = strchr(pSlash, slash)) == NULL )	    return OK;	*pSlash = '\0' ;	if ( stat( tmpName, &st ) == OK )	    {	    if( S_ISDIR(st.st_mode ) == 0)		{		printErr("Path %s is not a directory\n", tmpName);		return ERROR;		}	    }	else	    {	    mkdir( tmpName );	    }	*pSlash = slash ;	/* restore slash position */	pSlash++;	}    printErr("Path too long %s\n", name );    return ERROR;    }/********************************************************************************* tarExtractFile - extract one file or directory from tar tape** Called from tarExtract for every file/dir found on tape.** RETURNS: OK or ERROR*/LOCAL STATUS tarExtractFile    (    MT_TAR_SOFT	*pCtrl,		/* control structure */    MT_HBLOCK	*pBlk,		/* header block */    BOOL	verbose		/* verbose */    )    {    register int rc, fd ;    int		sum = -1 ;		/* checksum */    int		size = 0 ;		/* file size in bytes */    int		nblks = 0;		/* file size in TBLOCKs */    int		mode ;    char *	fn ;			/* file/dir name */    /* Check the checksum of this header */    rc = sscanf( pBlk->dbuf.chksum, "%o", &sum ) ;	/* extract checksum */    bfill( pBlk->dbuf.chksum, 8, ' ');		/* fill blanks */    if( mtChecksum( pBlk->dummy, TBLOCK ) != sum )	{	printErr("bad checksum %d != %d\n", mtChecksum(		pBlk->dummy, TBLOCK), sum );	return ERROR;	}    /* Parse all fields of header that we need, and store them safely */    sscanf( pBlk->dbuf.mode, "%o", &mode );    sscanf( pBlk->dbuf.size, "%12o", &size );    fn = pBlk->dbuf.name ;    /* Handle directory */    if( (size == 0) && ( fn[ strlen(fn) - 1 ] == '/' ) )	{	if( strcmp(fn, "./") == 0)	    return OK;	if ( fn[ strlen(fn) - 1 ] == '/' )	/* cut the slash */	    fn[ strlen(fn) - 1 ] = '\0' ;	/* Must make sure that parent exists for this new directory */	if ( mtAccess(fn) == ERROR )	    {	    return ERROR;	    }	fd = open (fn, O_RDWR | O_CREAT, FSTAT_DIR | (mode & 0777) );	if (( fd == ERROR ) && (errnoGet() == S_dosFsLib_FILE_EXISTS))	    {	    printErr("Warning: directory %s already exists\n", fn );	    return OK;	    }	else if (fd == ERROR)	    {	    printErr("failed to create directory %s, %s, continuing\n",		     fn, strerror(errnoGet()));	    return OK;	    }	if(verbose)	    printErr("created directory %s.\n", fn );	return (close (fd));	}    /* non-empty file has a trailing slash, we better treat it as file and */    if ( fn[ strlen(fn) - 1 ] == '/' )	/* cut a trailing slash */	fn[ strlen(fn) - 1 ] = '\0' ;    /* Filter out links etc */    if ((pBlk->dbuf.linkflag != '\0') &&    	(pBlk->dbuf.linkflag != '0') &&	(pBlk->dbuf.linkflag != ' '))	{	printErr("we do not support links, %s skipped\n", fn );	return OK;	}    /* Handle Regular File - calculate number of blocks */    if( size > 0 )	nblks = ( size / TBLOCK ) +  ((size % TBLOCK)? 1 : 0 ) ;    /* Must make sure that directory exists for this new file */    if ( mtAccess(fn) == ERROR )	{	return ERROR;	}    /* Create file */    fd = open( fn, O_RDWR | O_CREAT, mode & 0777 ) ;    if( fd == ERROR )	{	printErr("failed to create file %s, %s, skipping!\n",		fn, strerror(errnoGet()));	fd = open( NULLDEV, O_RDWR, 0) ;	}    if(verbose)	printErr("extracting file %s, size %d bytes, %d blocks\n",		fn, size, nblks );    /* Loop until entire file extracted */    while (size > 0)	{	MT_HBLOCK *pBuf;	register int wc ;	rc = tarRdBlks( pCtrl, &pBuf, nblks) ;	if ( rc < 0 )	    {	    printErr("error reading tape\n");	    close(fd);	    return ERROR;	    }	wc = write( fd, pBuf->dummy, min( rc*TBLOCK, size ) ) ;	if( wc == ERROR )	    {	    printErr("error writing file\n");	    break;	    }	size -= rc*TBLOCK ;	nblks -= rc ;	}    /* Close the newly created file */    return( close(fd) ) ;    }/********************************************************************************* tarExtract - extract all files from a tar formatted tape** This is a UNIX-tar compatible utility that extracts entire* file hierarchies from tar-formatted archive.* The files are extracted with their original names and modes.* In some cases a file cannot be created on disk, for example if* the name is too long for regular DOS file name conventions,* in such cases entire files are skipped, and this program will* continue with the next file. Directories are created in order* to be able to create all files on tape.** The <tape> argument may be any tape device name or file name* that contains a tar formatted archive. If <tape> is equal "-",* standard input is used. If <tape> is NULL (or unspecified from Shell)* the default archive file name stored in global variable <TAPE> is used.** The <bfactor> dictates the blocking factor the tape was written with.* If 0, or unspecified from the shell, a default of 20 is used.** The <verbose> argument is a boolean, if set to 1, will cause informative* messages to be printed to standard error whenever an action is taken,* otherwise, only errors are reported.** All informative and error message are printed to standard error.** There is no way to selectively extract tar archives with this* utility. It extracts entire archives.*/STATUS tarExtract    (    char *	pTape,		/* tape device name */    int		bfactor,	/* requested blocking factor */    BOOL	verbose		/* if TRUE print progress info */    )    {    register 	int rc ;		/* return codes */    MT_TAR_SOFT	ctrl ;		/* control structure */    STATUS	retval = OK;    /* Set defaults */    if( pTape == NULL )	pTape = TAPE ;    if( bfactor == 0 )	bfactor = 20 ;    if( verbose )	printErr("Extracting from %s\n", pTape );    bzero( (char *)&ctrl, sizeof(ctrl) );    bzero( bZero, sizeof(bZero) );	/* not harmful for reentrancy */    /* Open tape device and initialize control structure */    if( strcmp(pTape, "-") == 0)	ctrl.fd = STD_IN;    else	ctrl.fd = open( pTape, O_RDONLY, 0) ;    if ( ctrl.fd < 0 )	{	printErr("Failed to open tape: %s\n", strerror(errnoGet()) );	return ERROR;	}        ctrl.bFactor = bfactor ;    ctrl.pBuf = KHEAP_ALLOC( bfactor * TBLOCK ) ;    if ( ctrl.pBuf == NULL )	{	printErr("Not enough memory, exiting.\n" );	if ( ctrl.fd != STD_IN )	    close( ctrl.fd );	return ERROR ;	}    /* all exits from now via goto in order to free the buffer */    /* Read the first block and adjust blocking factor */    rc = read( ctrl.fd, ctrl.pBuf->dummy, ctrl.bFactor*TBLOCK ) ;    if ( rc == ERROR )	{	printErr("read error at the beginning of tape, exiting.\n" );	retval = ERROR ;	goto finish;	}    else if( rc == 0 )	{	printErr("empty tape file, exiting.\n" );	goto finish;	}    else if( (rc % TBLOCK) != 0 )	{	printErr("tape block not multiple of %d, exiting.\n", TBLOCK);	retval = ERROR ;	goto finish;	}    ctrl.bValid = rc / TBLOCK ;    ctrl.pBnext = ctrl.pBuf ;    if ( ctrl.bFactor != ctrl.bValid )	{	if( verbose )	    printErr("adjusting blocking factor to %d\n", ctrl.bValid );	ctrl.bFactor = ctrl.bValid ;	}    /* End of overture, start processing files until end of tape */    FOREVER	{	MT_HBLOCK *	pBlk ;	if ( tarRdBlks( &ctrl, &pBlk, 1) != 1 )	    {	    retval = ERROR ;	    goto finish;	    }	if ( bcmp( pBlk->dummy, bZero, TBLOCK) == 0 )	    {	    if(verbose)		printErr("end of tape encountered, read until eof...\n");	    while( tarRdBlks( &ctrl, &pBlk, 1) > 0) ;	    if(verbose)		printErr("done.\n");	    retval = OK ;	    goto finish;	    }	if ( tarExtractFile( &ctrl, pBlk, verbose) == ERROR )	    {	    retval = ERROR;	    goto finish;	    }	} /* end of FOREVER */    finish:	if ( ctrl.fd != STD_IN )	    close( ctrl.fd );	KHEAP_FREE((char *)ctrl.pBuf );	return( retval );    }/********************************************************************************* tarWrtBlks - write <nBlocks> blocks to tape** Receives any number of blocks, and handles the blocking factor* mechanism using the pCtrl->pBuf internal buffer and associated* counters.** RETURNS: OK or ERROR;*/LOCAL STATUS tarWrtBlks    (    MT_TAR_SOFT *pCtrl,		/* control structure */    char *pBuf,			/* data to write */    unsigned int nBlocks	/* how many blocks to get */    )    {    register int rc ;    while( nBlocks > 0 )	{	if ((pCtrl->bValid <= 0) && (nBlocks >= (unsigned int)pCtrl->bFactor))	    {	    /* internal buffer empty, write directly */	    rc = write( pCtrl->fd, pBuf, pCtrl->bFactor*TBLOCK ) ;	    if ( rc == ERROR )		return ERROR ;	    /* adjust count and pointer */	    pBuf += TBLOCK * pCtrl->bFactor ;	    nBlocks -= pCtrl->bFactor ;	    }	else 	    {	    register int cnt ;	    /* internal buffer partially full, fill it up */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天免费综合色| 国产一区二区久久| 国内偷窥港台综合视频在线播放| 免费在线看一区| 99国产精品久久久久| 欧美三级乱人伦电影| 久久这里只有精品视频网| 亚洲人精品午夜| 毛片av一区二区三区| av一区二区三区在线| 精品日韩一区二区三区| 中文字幕在线不卡一区| 精品写真视频在线观看| 99久久er热在这里只有精品66| 欧美日韩一区三区四区| 中文子幕无线码一区tr| 六月丁香综合在线视频| 在线视频一区二区免费| 国产精品热久久久久夜色精品三区 | 99综合影院在线| 51午夜精品国产| 午夜一区二区三区在线观看| 久久精品999| 777奇米四色成人影色区| 一区二区三区国产豹纹内裤在线| 国产一区欧美日韩| 7777精品久久久大香线蕉| 亚洲成人激情综合网| 欧洲一区在线观看| 亚洲综合视频网| 欧美三级乱人伦电影| 午夜精品视频在线观看| 在线不卡中文字幕| 三级在线观看一区二区| 欧美日韩成人一区| 日本欧美在线观看| 日韩欧美国产wwwww| 久久国产成人午夜av影院| 亚洲精品在线免费观看视频| 国产中文一区二区三区| 国产女同互慰高潮91漫画| 国产99久久久久久免费看农村| 亚洲国产精品t66y| 日本韩国一区二区三区视频| 午夜免费久久看| 久久人人爽爽爽人久久久| 国产a级毛片一区| 五月天亚洲精品| 国产女同性恋一区二区| 欧美日本韩国一区二区三区视频| 日韩中文字幕亚洲一区二区va在线| 欧美精品久久99| 高清国产一区二区| 首页国产欧美久久| 成人免费在线播放视频| 日韩视频123| 欧美日韩在线播放三区四区| 国产精品资源站在线| 日韩精品一级二级| 一区二区三区精品视频在线| 久久午夜国产精品| 777a∨成人精品桃花网| 91啪在线观看| 国产精品一区二区视频| 日本美女视频一区二区| 国产三级精品三级在线专区| 日本成人中文字幕| 91精品国产免费久久综合| 亚洲免费av高清| 欧美成人在线直播| 国产精品美女www爽爽爽| 亚洲欧洲综合另类| 强制捆绑调教一区二区| 国产精品亚洲第一区在线暖暖韩国| 高清国产一区二区| 丰满少妇久久久久久久| 国产一区二区三区蝌蚪| 国产在线播放一区| 国产精品自产自拍| 国产高清久久久久| 成人av在线电影| 97久久久精品综合88久久| 成人短视频下载| 色噜噜狠狠成人中文综合| 欧美日韩一区二区三区高清| 欧美日韩国产天堂| 日韩精品综合一本久道在线视频| 久久青草欧美一区二区三区| 国产精品久久久久影视| 亚洲一区二区三区四区中文字幕 | 91亚洲永久精品| 欧美三区免费完整视频在线观看| 欧美亚洲综合久久| 久久久蜜臀国产一区二区| 一级精品视频在线观看宜春院| 中文字幕一区二区5566日韩| 亚洲激情五月婷婷| 久久不见久久见中文字幕免费| 天堂成人国产精品一区| 国产v日产∨综合v精品视频| 欧美影视一区二区三区| 欧美高清在线精品一区| 午夜成人免费电影| 95精品视频在线| 精品国产91久久久久久久妲己| 亚洲一区二区精品视频| 国内精品国产三级国产a久久| 91久久线看在观草草青青| 国产欧美日本一区视频| 久久国产麻豆精品| 欧美高清精品3d| 亚洲免费电影在线| 91天堂素人约啪| 中文字幕av一区二区三区免费看 | 一区二区三区欧美激情| 国产精品99久| 久久先锋影音av鲁色资源网| 亚洲韩国一区二区三区| 色老汉一区二区三区| 国产精品久久久久一区二区三区| 国产成人综合亚洲91猫咪| 久久蜜臀精品av| 久久精品噜噜噜成人88aⅴ | 国产91精品入口| 国产精品久久毛片| 日本精品裸体写真集在线观看| 亚洲欧美日韩久久| 欧美一区二区三区四区视频| 午夜av区久久| 亚洲国产精品t66y| 欧美在线视频全部完| 欧美激情在线观看视频免费| 成人99免费视频| 国产精品的网站| 欧美视频自拍偷拍| 九九九精品视频| 国产精品萝li| 欧美日韩国产一级| 国内精品久久久久影院色| 国产精品每日更新在线播放网址| 色婷婷一区二区| 久草精品在线观看| 亚洲欧美偷拍三级| 欧美一级电影网站| 成人精品国产福利| 青青草国产精品亚洲专区无| 国产精品毛片无遮挡高清| 欧美大片拔萝卜| 色婷婷亚洲综合| 不卡视频一二三四| 久久精品国产一区二区三区免费看 | 国产福利精品导航| 日韩av一区二区三区四区| 国产精品久久久久久久久果冻传媒 | 欧美精品一级二级| 99re亚洲国产精品| 成人性生交大片| 精品系列免费在线观看| 一区二区成人在线| 综合在线观看色| 久久久影视传媒| 精品999久久久| 欧美一区二区三区电影| 欧美日韩精品免费| 在线看国产日韩| 日本福利一区二区| 91久久免费观看| 欧美日韩免费观看一区二区三区 | 成人国产视频在线观看| 成人黄色a**站在线观看| 国产成人免费高清| 国产精品一区在线| 国产69精品一区二区亚洲孕妇 | 久久一区二区视频| 欧美精品一区二区三区视频| 久久九九影视网| 自拍偷在线精品自拍偷无码专区| 中文字幕一区二区在线播放| 亚洲欧洲99久久| 亚洲一卡二卡三卡四卡五卡| 五月天激情综合| 久久国产尿小便嘘嘘尿| 国产福利不卡视频| 色综合久久88色综合天天免费| 欧美午夜精品久久久久久孕妇| 色素色在线综合| 欧美三级电影在线观看| 91精品国产综合久久久久久久| 精品国偷自产国产一区| 最近日韩中文字幕| 日本女人一区二区三区| av在线不卡观看免费观看| 欧美日韩国产欧美日美国产精品| 日韩精品专区在线影院重磅| 亚洲日本一区二区| 免费观看91视频大全| 色综合久久久久网| 精品国产乱码久久久久久老虎| 国产精品美女久久久久aⅴ | 欧美mv和日韩mv的网站|