book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!







SKIPBYTE.C Tony Lawrence:




#include <stdio.h>
char buf[4096];


Hate these ads?



main(int argc, char **argv)
{
long skip=0;
unsigned long total=0;
unsigned long outp=0;
FILE *of,*nf;



int x;
size_t count=1;



if (argc < 4 || argc > 5)
  help_exit(1);



 skip=atol(argv[3]);
 if (argc == 5)
   total=atol(argv[3]);








if ((of=fopen(argv[1],"rb"))==NULL)
     {
     printf("No %s file??\n",argv[0]);
     help_exit(1);
     }
if ((nf=fopen(argv[2],"w"))==NULL)
     {
     printf("No %s file??\n",argv[0]);
     help_exit(1);
     }
if(skip)
 fseek(of,skip,SEEK_SET);
if (!total)
{
while (1)
{
long bread;



bread=fread(buf,4096,1,of);
printf(" %d ",bread);
if( !bread) break;
fwrite(buf,bread,1,nf);
printf(".");
}
}
else
{
 while (outp < total)
 {
 long bsize;
 long bread;


 
 bsize=4096;
 if (total - outp < 4096)
   bsize=total-outp;



bread=fread(buf,bsize,1,of);
printf(" %d ",bread);
if( !bread) break;
fwrite(buf,bsize,1,nf);
printf(".");
outp += bread;
 }
}
fclose(of);
fclose(nf);
printf("\n");
exit(0);
}


ad



help_exit(int arg)
{
 printf("\n\nSKIPBYTE oldfile newfile skip-bytes [total-bytes]\n");
 printf("Reads 'oldfile' skipping 'skip-bytes' bytes and stopping\n");
 printf("after 'total-bytes' are copied (copied to newfile, not read\n");
 printf("from oldfile\n");
 printf("'total-bytes' is optional\n");
 printf("\n\n(C)1993 Lawrence & Clark, Inc (781) 784-5537 (206) 323-2864\n\n\n");
 exit(arg);
}












Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


Views for this page
Today This Week This Month This Year  Overall
2799 894

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:




Unix/Linux Consultants


UBB Computer Services Support for Openserver, Unixware and Linux. Windows integration with Unix/Linux servers. Hardware, Backup and Networking issues. Located near Sacramento CA, we provide onsite support throughout Northern CA and Nationwide via remote access. We are a SCO Authorized Partner and a Microlite BackupEdge Certified Reseller.


larryi@ccamedical.com SCO OS5, Debian Linux, RedHat Linux, MySQL, Apache, AJAX development using dXport/dL4/Unibasic, Windows Connectivity, Sharing Resouces, Automation, Shell Scripting


http://thatitguy.com Business networking servers, Linux and Unix experts. In business since 1997! Windows and Exchange to Samba and Scalix migration experts.



Twitter
o I knew today would be Monday - it's so predictable! 6:02 AM Mar 10th 2008








Change Congress