]>
Commit | Line | Data |
---|---|---|
14c7c974 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
f083c6c3 A |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
7 | * | |
8 | * This file contains Original Code and/or Modifications of Original Code | |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14c7c974 A |
14 | * |
15 | * The Original Code and all software distributed under the License are | |
f083c6c3 | 16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
14c7c974 A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
f083c6c3 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
14c7c974 A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright 1993 NeXT, Inc. | |
27 | * All rights reserved. | |
28 | */ | |
29 | ||
30 | #import "libsa.h" | |
31 | ||
32 | /* | |
33 | * This routine returns the segment_command structure for the named segment if | |
34 | * it exist in the mach executible it is linked into. Otherwise it returns | |
35 | * zero. It uses the specified mach_header pointer and just looks through the | |
36 | * load commands. | |
37 | */ | |
38 | struct segment_command * | |
39 | getsegbynamefromheader( | |
40 | struct mach_header *mhp, | |
41 | char *segname) | |
42 | { | |
43 | struct segment_command *sgp; | |
44 | long i; | |
45 | ||
46 | sgp = (struct segment_command *) | |
47 | ((char *)mhp + sizeof(struct mach_header)); | |
48 | for(i = 0; i < mhp->ncmds; i++){ | |
49 | if(sgp->cmd == LC_SEGMENT) | |
50 | if(strncmp(sgp->segname, segname, sizeof(sgp->segname)) == 0) | |
51 | return(sgp); | |
52 | sgp = (struct segment_command *)((char *)sgp + sgp->cmdsize); | |
53 | } | |
54 | return((struct segment_command *)0); | |
55 | } |