view tool/patchhook.c @ 8:04fd47d382c7

ti-libpatch: ar member timestamp patching fixed
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 06 Jun 2015 05:24:23 +0000
parents 87e9f30f5f86
children
line wrap: on
line source

/*
 * This module implements the "patch hook" that checks if an archive member
 * needs to be patched and invokes all necessary patch processing.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include "ar.h"
#include "globals.h"
#include "patchinfo.h"

extern struct ar_hdr ar_hdr;

update_ar_timestamp()
{
	time_t curtime;
	char tmpbuf[13];

	time(&curtime);
	sprintf(tmpbuf, "%-12lu", (u_long) curtime);
	bcopy(tmpbuf, ar_hdr.ar_date, 12);
}

patch_hook()
{
	struct patch_module_desc *pmd;
	struct patch_desc *patch;

	for (pmd = patch_module_list; pmd; pmd = pmd->next)
		if (!strcmp(pmd->member_name, member_name))
			break;
	if (!pmd)
		return(0);
	/* yes, we need to patch it: start digging into it */
	parse_coff_hdr();
	for (patch = pmd->patches; patch; patch = patch->next)
		apply_patch(patch);
	update_ar_timestamp();
	return(1);
}