/* * Copyright (C) 2002-2005 Roman Zippel * Copyright (C) 2002-2005 Sam Ravnborg * * Released under the terms of the GNU GPL v2.0. */ #include #include "lkc.h" /* file already present in list? If not add it */ struct file *file_lookup(const char *name) { struct file *file; for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) return file; } file = malloc(sizeof(*file)); memset(file, 0, sizeof(*file)); file->name = strdup(name); file->next = file_list; file_list = file; return file; } /* Allocate initial growable sting */ struct gstr str_new(void) { struct gstr gs; gs.s = malloc(sizeof(char) * 64); gs.len = 16; strcpy(gs.s, "\0"); return gs; } /* Allocate and assign growable string */ struct gstr str_assign(const char *s) { struct gstr gs; gs.s = strdup(s); gs.len = strlen(s) + 1; return gs; } /* Free storage for growable string */ void str_free(struct gstr *gs) { if (gs->s) free(gs->s); gs->s = NULL; gs->len = 0; } /* Append to growable string */ void str_append(struct gstr *gs, const char *s) { size_t l = strlen(gs->s) + strlen(s) + 1; if (l > gs->len) { gs->s = realloc(gs->s, l); gs->len = l; } strcat(gs->s, s); } /* Append printf formatted string to growable string */ void str_printf(struct gstr *gs, const char *fmt, ...) { va_list ap; char s[10000]; /* big enough... */ va_start(ap, fmt); vsnprintf(s, sizeof(s), fmt, ap); str_append(gs, s); va_end(ap); } /* Retrieve value of growable string */ const char *str_get(struct gstr *gs) { return gs->s; } ight'>James
aboutsummaryrefslogtreecommitdiffstats
blob: 44865788900cfab8ba6b4b4343f7115a2998712b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=mtd
PKG_VERSION:=20050122

PKG_SOURCE=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
PKG_SOURCE_URL=http://ftp.debian.org/debian/pool/main/m/mtd
PKG_MD5SUM:=1f42c2cae08eb9e7b52d0c188f8d6338
PKG_CAT:=zcat

HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION).orig

include $(INCLUDE_DIR)/host-build.mk

CFLAGS := $(HOST_CFLAGS) -I../include
ifneq ($(HOST_OS),Linux)
CFLAGS += -Dloff_t=off_t -D__BYTE_ORDER=BYTE_ORDER -include getline.h -include endian.h
endif

define Host/Compile
	$(MAKE) -C $(HOST_BUILD_DIR)/util CFLAGS="$(CFLAGS)" TARGETS=mkfs.jffs2
endef

define Host/Install
	$(CP) $(HOST_BUILD_DIR)/util/mkfs.jffs2 $(STAGING_DIR_HOST)/bin/
endef

define Host/Clean
	rm -f $(STAGING_DIR_HOST)/bin/mkfs.jffs2
endef

$(eval $(call HostBuild))