From owner-freebsd-hackers Sat Mar 16 14:31:38 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from cauchy.clarkevans.com (209-9-30-66.sdsl.cais.net [209.9.30.66]) by hub.freebsd.org (Postfix) with ESMTP id D185837B427 for ; Sat, 16 Mar 2002 14:31:25 -0800 (PST) Received: from cce by cauchy.clarkevans.com with local (Exim 3.33 #1) id 16mMjO-00042u-00 for hackers@freebsd.org; Sat, 16 Mar 2002 17:32:54 -0500 Date: Sat, 16 Mar 2002 17:32:54 -0500 From: "Clark C . Evans" To: hackers@freebsd.org Subject: simple binary patch utility (for iso cdrom images) Message-ID: <20020316173254.A15494@doublegemini.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I looked around for quite a while for a simple program to do a binary patch on an iso cdrom image. I was hoping that I could use "bvi" or similar binary editor, but it wasn't clear how I could get them to do simple string replacement. So, I wrote one and am putting it in the public domain, I hope someone finds it useful. #include #include #include #define TRUE -1 #define FALSE 0 long findstr(FILE *file, const char *str,int len) { long r = 0; int c = 0; int i = 0; while(-1 != (c=fgetc(file))) { if(str[i] == ((char)c)) { i++; if(i\n", argv[1]); return; } pos = findstr(file,find,len); if (!pos) { printf("Unable to find string '%s'\n",find); return; } fseek(file,pos,SEEK_SET); fwrite(repl,1,len,file); fclose( file ); } -- Clark C. Evans Axista, Inc. http://www.axista.com 800.926.5525 XCOLLA Collaborative Project Management Software To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message