Skip to content

Commit

Permalink
Initial revision.
Browse files Browse the repository at this point in the history
  • Loading branch information
nygard committed Jul 31, 1999
1 parent 2c25918 commit af02f41
Show file tree
Hide file tree
Showing 36 changed files with 4,639 additions and 0 deletions.
54 changes: 54 additions & 0 deletions MappedFile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// $Id: MappedFile.h,v 1.1 1999/07/31 03:32:26 nygard Exp $
//

//
// This file is a part of class-dump v2, a utility for examining the
// Objective-C segment of Mach-O files.
// Copyright (C) 1997 Steve Nygard
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// You may contact the author by:
// e-mail: [email protected]
//

#include <sys/types.h>
#include <sys/stat.h>

#if NS_TARGET_MAJOR >= 4
#import <Foundation/Foundation.h>
#else
#import <foundation/NSString.h>
#import <foundation/NSData.h>
#endif

// And most of this could be done with NSData - initWithContentsOfMappedFile:

@interface MappedFile : NSObject
{
NSString *filename;
NSData *data;
}

- initWithFilename:(NSString *)aFilename;
- (void) dealloc;

- (NSString *) filename;
- (const void *) data;

- (NSString *) pathToMainFileOfWrapper:(NSString *)path;

@end
131 changes: 131 additions & 0 deletions MappedFile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//
// $Id: MappedFile.m,v 1.1 1999/07/31 03:32:27 nygard Exp $
//

//
// This file is a part of class-dump v2, a utility for examining the
// Objective-C segment of Mach-O files.
// Copyright (C) 1997 Steve Nygard
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// You may contact the author by:
// e-mail: [email protected]
//

#import "MappedFile.h"
#if NS_TARGET_MAJOR < 4
#import <foundation/NSArray.h>
#import <foundation/NSException.h>
#import <foundation/NSPathUtilities.h>
#import <foundation/NSUtilities.h>

@interface NSString (Foundation4PathCompatibility)
- (NSArray *)pathComponents;
@end

@implementation NSString (Foundation4PathCompatibility)
- (NSArray *)pathComponents
{
return [self componentsSeparatedByString:@"/"];
}
@end

#endif

#include <stdio.h>
#include <libc.h>
#include <ctype.h>

@implementation MappedFile

// Will map filename into memory. If filename is a directory with specific suffixes, treat the directory as a wrapper.

- initWithFilename:(NSString *)aFilename
{
NSString *standardPath;
#if (NS_TARGET_MAJOR >= 4)
NSMutableSet *wrappers = [NSMutableSet set];
#else
// for foundation 3.x (less efficient than a set but at least it works...)
NSMutableArray *wrappers = [NSMutableArray array];
#endif
if ([super init] == nil)
return nil;

standardPath = [aFilename stringByStandardizingPath];

[wrappers addObject:@"app"];
[wrappers addObject:@"framework"];
[wrappers addObject:@"bundle"];
[wrappers addObject:@"palette"];

if ([wrappers containsObject:[standardPath pathExtension]] == YES)
{
standardPath = [self pathToMainFileOfWrapper:standardPath];
}

data = [[NSData dataWithContentsOfMappedFile:standardPath] retain];
if (data == nil)
{
NSLog (@"Couldn't map file: %@", standardPath);
return nil;
}

filename = [standardPath retain];

return self;
}

- (void) dealloc
{
[data release];
[filename release];

[super dealloc];
}

- (NSString *) filename
{
return filename;
}

- (const void *) data
{
return [data bytes];
}

// How does this handle something ending in "/"?

- (NSString *) pathToMainFileOfWrapper:(NSString *)path
{
NSRange range;
NSMutableString *tmp;
NSString *extension;
NSString *base;

base = [[path pathComponents] lastObject];
NSAssert (base != nil, @"No base.");

extension = [NSString stringWithFormat:@".%@", [base pathExtension]];

tmp = [NSMutableString stringWithFormat:@"%@/%@", path, base];
range = [tmp rangeOfString:extension options:NSBackwardsSearch];
[tmp deleteCharactersInRange:range];

return tmp;
}

@end
52 changes: 52 additions & 0 deletions Nextstep/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Generated by the NeXT Project Builder.
#
# NOTE: Do NOT change this file -- Project Builder maintains it.
#
# Put all of your customizations in files called Makefile.preamble
# and Makefile.postamble (both optional), and Makefile will include them.
#

NAME = class-dump

PROJECTVERSION = 2.6
LANGUAGE = English

CLASSES = MappedFile.m ObjcCategory.m ObjcClass.m ObjcIvar.m\
ObjcMethod.m ObjcProtocol.m ObjcThing.m

HFILES = class-dump.h datatypes.h MappedFile.h ObjcCategory.h\
ObjcClass.h ObjcIvar.h ObjcMethod.h ObjcProtocol.h\
ObjcThing.h my_regex.h

OTHERLINKED = gram.y

MFILES = class-dump.m datatypes.m

CFILES = lexer.c my_regex.c

OTHERSRCS = Makefile.preamble Makefile Makefile.postamble m.template\
h.template

OTHERLINKEDOFILES = gram.o

MAKEFILEDIR = /NextDeveloper/Makefiles/app
MAKEFILE = tool.make
INSTALLDIR = /usr/local/bin
INSTALLFLAGS = -c -s -m 755
SOURCEMODE = 444

LIBS = -lFoundation_s
DEBUG_LIBS = $(LIBS)
PROF_LIBS = $(LIBS)




-include Makefile.preamble

include $(MAKEFILEDIR)/$(MAKEFILE)

-include Makefile.postamble

-include Makefile.dependencies
117 changes: 117 additions & 0 deletions Nextstep/Makefile.postamble
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
###############################################################################
# NeXT Makefile.postamble Template
# Copyright 1993, NeXT Computer, Inc.
#
# This Makefile is used for configuring the standard app makefiles associated
# with ProjectBuilder.
#
# Use this template to set attributes for a project, sub-project, bundle, or
# palette. Each node in the project's tree of sub-projects and bundles
# should have it's own Makefile.preamble and Makefile.postamble. Additional
# rules (e.g., after_install) that are defined by the developer should be
# defined in this file.
#
###############################################################################
#
# Here are the variables exported by the common "app" makefiles that can be
# used in any customizations you make to the template below:
#
# PRODUCT_ROOT - Name of top-level app-wrapper (e.g., Webster.app)
# OFILE_DIR - Directory into which .o object files are generated.
# (Note that this name is calculated based on the target
# architectures specified in Project Builder).
# DERIVED_SRC_DIR - Directory used for all other derived files
# ALL_CFLAGS - All the flags passed to the cc(1) driver for compilations
#
# NAME - name of application, bundle, subproject, palette, etc.
# LANGUAGE - langage in which the project is written (default "English")
# ENGLISH - boolean flag set iff $(LANGUAGE) = "English"
# JAPANESE - boolean flag set iff $(LANGUAGE) = "Japanese"
# LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project
# GLOBAL_RESOURCES - non-localized resources of project
# PROJECTVERSION - version of ProjectBuilder that output Makefile
# APPICON - application icon file
# DOCICONS - dock icon files
# ICONSECTIONS - Specifies icon sections when linking executable
#
# CLASSES - Class implementation files in project.
# HFILES - Header files in project.
# MFILES - Other Objective-C source files in project.
# CFILES - Other C source files in project.
# PSWFILES - .psw files in the project
# PSWMFILES - .pswm files in the project
# SUBPROJECTS - Subprojects of this project
# BUNDLES - Bundle subprojects of this project
# OTHERSRCS - Other miscellaneous sources of this project
# OTHERLINKED - Source files not matching a standard source extention
#
# LIBS - Libraries to link with when making app target
# DEBUG_LIBS - Libraries to link with when making debug target
# PROF_LIBS - Libraries to link with when making profile target
# OTHERLINKEDOFILES - Other relocatable files to (always) link in.
#
# APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles
# MAKEFILEDIR - Directory in which to find $(MAKEFILE)
# MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make)
# INSTALLDIR - Directory app will be installed into by 'install' target


# Change defaults assumed by the standard app makefiles here. Edit the
# following default values as appropriate. (Note that if no Makefile.postamble
# exists, these values will have defaults set in common.make).

# Add Makefile.preamble, Makefile.postamble, and Makefile.dependencies here if
# you would like changes to them to invalidate previous builds. The project
# depends on $(MAKEFILES) so that changes to Makefiles will trigger a re-build.
#MAKEFILES = Makefile

# Optimization flag passed to compiler:
#OPTIMIZATION_CFLAG = -O

# Flags always passed to compiler:
#COMMON_CFLAGS = $(PROJECT_SPECIFIC_CFLAGS) -g -Wall

# Flags passed to compiler in normal 'app' compiles:
#NORMAL_CFLAGS = $(COMMON_CFLAGS) $(OPTIMIZATION_CFLAG)

# Flags passed to compiler in 'debug' compiles:
#DEBUG_CFLAGS = $(COMMON_CFLAGS) -DDEBUG

# Flags passed to compiler in 'profile' compiles
#PROFILE_CFLAGS = $(COMMON_CFLAGS) -pg $(OPTIMIZATION_CFLAG) -DPROFILE

# Flags passed to yacc
#YFLAGS = -d

# Ownership and permissions of files installed by 'install' target
#INSTALL_AS_USER = root # User to chown app to
#INSTALL_AS_GROUP = wheel # Group to chgrp app to
#INSTALL_PERMISSIONS = # If set, 'install' chmod's executable to this

# Options to strip for bundles, apps with bundles, and apps without bundles,
# respectively.
#RELOCATABLE_STRIP_OPTS = -x -u
#DYLD_APP_STRIP_OPTS = -A -n
#APP_STRIP_OPTS =
#TOOL_STRIP_OPTS =
#LIBRARY_STRIP_OPTS = -x -S # Note: -S strips debugging symbols
# (Note: APP_STRIP_OPTS and TOOL_STRIP_OPTS default to empty, but
# developers doing their own dynamic loading should set this to
# $(DYLD_APP_STRIP_OPTS)).


#########################################################################
# Put rules to extend the behavior of the standard Makefiles here. Typical
# user-defined rules are before_install and after_install (please don't
# redefine things like install or app, as they are owned by the top-level
# Makefile API), which are rules that get invoked before and after the install
# target runs. Such rules should be specified with the '::' syntax rather than
# a single colon.

YFLAGS = --yacc -d
YACC = bison
LEX = flex




Loading

0 comments on commit af02f41

Please sign in to comment.