Skip to content

Commit af02f41

Browse files
committed
Initial revision.
1 parent 2c25918 commit af02f41

36 files changed

+4639
-0
lines changed

MappedFile.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// $Id: MappedFile.h,v 1.1 1999/07/31 03:32:26 nygard Exp $
3+
//
4+
5+
//
6+
// This file is a part of class-dump v2, a utility for examining the
7+
// Objective-C segment of Mach-O files.
8+
// Copyright (C) 1997 Steve Nygard
9+
//
10+
// This program is free software; you can redistribute it and/or modify
11+
// it under the terms of the GNU General Public License as published by
12+
// the Free Software Foundation; either version 2 of the License, or
13+
// (at your option) any later version.
14+
//
15+
// This program is distributed in the hope that it will be useful,
16+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
// GNU General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU General Public License
21+
// along with this program; if not, write to the Free Software
22+
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23+
//
24+
// You may contact the author by:
25+
26+
//
27+
28+
#include <sys/types.h>
29+
#include <sys/stat.h>
30+
31+
#if NS_TARGET_MAJOR >= 4
32+
#import <Foundation/Foundation.h>
33+
#else
34+
#import <foundation/NSString.h>
35+
#import <foundation/NSData.h>
36+
#endif
37+
38+
// And most of this could be done with NSData - initWithContentsOfMappedFile:
39+
40+
@interface MappedFile : NSObject
41+
{
42+
NSString *filename;
43+
NSData *data;
44+
}
45+
46+
- initWithFilename:(NSString *)aFilename;
47+
- (void) dealloc;
48+
49+
- (NSString *) filename;
50+
- (const void *) data;
51+
52+
- (NSString *) pathToMainFileOfWrapper:(NSString *)path;
53+
54+
@end

MappedFile.m

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
//
2+
// $Id: MappedFile.m,v 1.1 1999/07/31 03:32:27 nygard Exp $
3+
//
4+
5+
//
6+
// This file is a part of class-dump v2, a utility for examining the
7+
// Objective-C segment of Mach-O files.
8+
// Copyright (C) 1997 Steve Nygard
9+
//
10+
// This program is free software; you can redistribute it and/or modify
11+
// it under the terms of the GNU General Public License as published by
12+
// the Free Software Foundation; either version 2 of the License, or
13+
// (at your option) any later version.
14+
//
15+
// This program is distributed in the hope that it will be useful,
16+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
// GNU General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU General Public License
21+
// along with this program; if not, write to the Free Software
22+
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23+
//
24+
// You may contact the author by:
25+
26+
//
27+
28+
#import "MappedFile.h"
29+
#if NS_TARGET_MAJOR < 4
30+
#import <foundation/NSArray.h>
31+
#import <foundation/NSException.h>
32+
#import <foundation/NSPathUtilities.h>
33+
#import <foundation/NSUtilities.h>
34+
35+
@interface NSString (Foundation4PathCompatibility)
36+
- (NSArray *)pathComponents;
37+
@end
38+
39+
@implementation NSString (Foundation4PathCompatibility)
40+
- (NSArray *)pathComponents
41+
{
42+
return [self componentsSeparatedByString:@"/"];
43+
}
44+
@end
45+
46+
#endif
47+
48+
#include <stdio.h>
49+
#include <libc.h>
50+
#include <ctype.h>
51+
52+
@implementation MappedFile
53+
54+
// Will map filename into memory. If filename is a directory with specific suffixes, treat the directory as a wrapper.
55+
56+
- initWithFilename:(NSString *)aFilename
57+
{
58+
NSString *standardPath;
59+
#if (NS_TARGET_MAJOR >= 4)
60+
NSMutableSet *wrappers = [NSMutableSet set];
61+
#else
62+
// for foundation 3.x (less efficient than a set but at least it works...)
63+
NSMutableArray *wrappers = [NSMutableArray array];
64+
#endif
65+
if ([super init] == nil)
66+
return nil;
67+
68+
standardPath = [aFilename stringByStandardizingPath];
69+
70+
[wrappers addObject:@"app"];
71+
[wrappers addObject:@"framework"];
72+
[wrappers addObject:@"bundle"];
73+
[wrappers addObject:@"palette"];
74+
75+
if ([wrappers containsObject:[standardPath pathExtension]] == YES)
76+
{
77+
standardPath = [self pathToMainFileOfWrapper:standardPath];
78+
}
79+
80+
data = [[NSData dataWithContentsOfMappedFile:standardPath] retain];
81+
if (data == nil)
82+
{
83+
NSLog (@"Couldn't map file: %@", standardPath);
84+
return nil;
85+
}
86+
87+
filename = [standardPath retain];
88+
89+
return self;
90+
}
91+
92+
- (void) dealloc
93+
{
94+
[data release];
95+
[filename release];
96+
97+
[super dealloc];
98+
}
99+
100+
- (NSString *) filename
101+
{
102+
return filename;
103+
}
104+
105+
- (const void *) data
106+
{
107+
return [data bytes];
108+
}
109+
110+
// How does this handle something ending in "/"?
111+
112+
- (NSString *) pathToMainFileOfWrapper:(NSString *)path
113+
{
114+
NSRange range;
115+
NSMutableString *tmp;
116+
NSString *extension;
117+
NSString *base;
118+
119+
base = [[path pathComponents] lastObject];
120+
NSAssert (base != nil, @"No base.");
121+
122+
extension = [NSString stringWithFormat:@".%@", [base pathExtension]];
123+
124+
tmp = [NSMutableString stringWithFormat:@"%@/%@", path, base];
125+
range = [tmp rangeOfString:extension options:NSBackwardsSearch];
126+
[tmp deleteCharactersInRange:range];
127+
128+
return tmp;
129+
}
130+
131+
@end

Nextstep/Makefile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Generated by the NeXT Project Builder.
3+
#
4+
# NOTE: Do NOT change this file -- Project Builder maintains it.
5+
#
6+
# Put all of your customizations in files called Makefile.preamble
7+
# and Makefile.postamble (both optional), and Makefile will include them.
8+
#
9+
10+
NAME = class-dump
11+
12+
PROJECTVERSION = 2.6
13+
LANGUAGE = English
14+
15+
CLASSES = MappedFile.m ObjcCategory.m ObjcClass.m ObjcIvar.m\
16+
ObjcMethod.m ObjcProtocol.m ObjcThing.m
17+
18+
HFILES = class-dump.h datatypes.h MappedFile.h ObjcCategory.h\
19+
ObjcClass.h ObjcIvar.h ObjcMethod.h ObjcProtocol.h\
20+
ObjcThing.h my_regex.h
21+
22+
OTHERLINKED = gram.y
23+
24+
MFILES = class-dump.m datatypes.m
25+
26+
CFILES = lexer.c my_regex.c
27+
28+
OTHERSRCS = Makefile.preamble Makefile Makefile.postamble m.template\
29+
h.template
30+
31+
OTHERLINKEDOFILES = gram.o
32+
33+
MAKEFILEDIR = /NextDeveloper/Makefiles/app
34+
MAKEFILE = tool.make
35+
INSTALLDIR = /usr/local/bin
36+
INSTALLFLAGS = -c -s -m 755
37+
SOURCEMODE = 444
38+
39+
LIBS = -lFoundation_s
40+
DEBUG_LIBS = $(LIBS)
41+
PROF_LIBS = $(LIBS)
42+
43+
44+
45+
46+
-include Makefile.preamble
47+
48+
include $(MAKEFILEDIR)/$(MAKEFILE)
49+
50+
-include Makefile.postamble
51+
52+
-include Makefile.dependencies

Nextstep/Makefile.postamble

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
###############################################################################
2+
# NeXT Makefile.postamble Template
3+
# Copyright 1993, NeXT Computer, Inc.
4+
#
5+
# This Makefile is used for configuring the standard app makefiles associated
6+
# with ProjectBuilder.
7+
#
8+
# Use this template to set attributes for a project, sub-project, bundle, or
9+
# palette. Each node in the project's tree of sub-projects and bundles
10+
# should have it's own Makefile.preamble and Makefile.postamble. Additional
11+
# rules (e.g., after_install) that are defined by the developer should be
12+
# defined in this file.
13+
#
14+
###############################################################################
15+
#
16+
# Here are the variables exported by the common "app" makefiles that can be
17+
# used in any customizations you make to the template below:
18+
#
19+
# PRODUCT_ROOT - Name of top-level app-wrapper (e.g., Webster.app)
20+
# OFILE_DIR - Directory into which .o object files are generated.
21+
# (Note that this name is calculated based on the target
22+
# architectures specified in Project Builder).
23+
# DERIVED_SRC_DIR - Directory used for all other derived files
24+
# ALL_CFLAGS - All the flags passed to the cc(1) driver for compilations
25+
#
26+
# NAME - name of application, bundle, subproject, palette, etc.
27+
# LANGUAGE - langage in which the project is written (default "English")
28+
# ENGLISH - boolean flag set iff $(LANGUAGE) = "English"
29+
# JAPANESE - boolean flag set iff $(LANGUAGE) = "Japanese"
30+
# LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project
31+
# GLOBAL_RESOURCES - non-localized resources of project
32+
# PROJECTVERSION - version of ProjectBuilder that output Makefile
33+
# APPICON - application icon file
34+
# DOCICONS - dock icon files
35+
# ICONSECTIONS - Specifies icon sections when linking executable
36+
#
37+
# CLASSES - Class implementation files in project.
38+
# HFILES - Header files in project.
39+
# MFILES - Other Objective-C source files in project.
40+
# CFILES - Other C source files in project.
41+
# PSWFILES - .psw files in the project
42+
# PSWMFILES - .pswm files in the project
43+
# SUBPROJECTS - Subprojects of this project
44+
# BUNDLES - Bundle subprojects of this project
45+
# OTHERSRCS - Other miscellaneous sources of this project
46+
# OTHERLINKED - Source files not matching a standard source extention
47+
#
48+
# LIBS - Libraries to link with when making app target
49+
# DEBUG_LIBS - Libraries to link with when making debug target
50+
# PROF_LIBS - Libraries to link with when making profile target
51+
# OTHERLINKEDOFILES - Other relocatable files to (always) link in.
52+
#
53+
# APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles
54+
# MAKEFILEDIR - Directory in which to find $(MAKEFILE)
55+
# MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make)
56+
# INSTALLDIR - Directory app will be installed into by 'install' target
57+
58+
59+
# Change defaults assumed by the standard app makefiles here. Edit the
60+
# following default values as appropriate. (Note that if no Makefile.postamble
61+
# exists, these values will have defaults set in common.make).
62+
63+
# Add Makefile.preamble, Makefile.postamble, and Makefile.dependencies here if
64+
# you would like changes to them to invalidate previous builds. The project
65+
# depends on $(MAKEFILES) so that changes to Makefiles will trigger a re-build.
66+
#MAKEFILES = Makefile
67+
68+
# Optimization flag passed to compiler:
69+
#OPTIMIZATION_CFLAG = -O
70+
71+
# Flags always passed to compiler:
72+
#COMMON_CFLAGS = $(PROJECT_SPECIFIC_CFLAGS) -g -Wall
73+
74+
# Flags passed to compiler in normal 'app' compiles:
75+
#NORMAL_CFLAGS = $(COMMON_CFLAGS) $(OPTIMIZATION_CFLAG)
76+
77+
# Flags passed to compiler in 'debug' compiles:
78+
#DEBUG_CFLAGS = $(COMMON_CFLAGS) -DDEBUG
79+
80+
# Flags passed to compiler in 'profile' compiles
81+
#PROFILE_CFLAGS = $(COMMON_CFLAGS) -pg $(OPTIMIZATION_CFLAG) -DPROFILE
82+
83+
# Flags passed to yacc
84+
#YFLAGS = -d
85+
86+
# Ownership and permissions of files installed by 'install' target
87+
#INSTALL_AS_USER = root # User to chown app to
88+
#INSTALL_AS_GROUP = wheel # Group to chgrp app to
89+
#INSTALL_PERMISSIONS = # If set, 'install' chmod's executable to this
90+
91+
# Options to strip for bundles, apps with bundles, and apps without bundles,
92+
# respectively.
93+
#RELOCATABLE_STRIP_OPTS = -x -u
94+
#DYLD_APP_STRIP_OPTS = -A -n
95+
#APP_STRIP_OPTS =
96+
#TOOL_STRIP_OPTS =
97+
#LIBRARY_STRIP_OPTS = -x -S # Note: -S strips debugging symbols
98+
# (Note: APP_STRIP_OPTS and TOOL_STRIP_OPTS default to empty, but
99+
# developers doing their own dynamic loading should set this to
100+
# $(DYLD_APP_STRIP_OPTS)).
101+
102+
103+
#########################################################################
104+
# Put rules to extend the behavior of the standard Makefiles here. Typical
105+
# user-defined rules are before_install and after_install (please don't
106+
# redefine things like install or app, as they are owned by the top-level
107+
# Makefile API), which are rules that get invoked before and after the install
108+
# target runs. Such rules should be specified with the '::' syntax rather than
109+
# a single colon.
110+
111+
YFLAGS = --yacc -d
112+
YACC = bison
113+
LEX = flex
114+
115+
116+
117+

0 commit comments

Comments
 (0)