Changeset 3575 for trunk/kStuff/kHlp/Generic
- Timestamp:
- Sep 2, 2007, 10:05:39 PM (18 years ago)
- Location:
- trunk/kStuff/kHlp/Generic
- Files:
-
- 1 added
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kHlp/Generic/kHlpGetExt.c
r3573 r3575 1 1 /* $Id$ */ 2 2 /** @file 3 * kHlpPath - kHlpGetExt and kHlpGetSuff. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kLdr - The Dynamic Loader, Path Helper Functions.9 * This file is part of kStuff. 5 10 * 6 * Copyright (c) 2006-2007 knut st. osmundsen <bird-kbuild-src@anduin.net> 11 * kStuff is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLdr. 10 * 11 * kLdr is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLdr is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLdr; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kStuff; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ 26 27 26 28 27 /******************************************************************************* … … 34 33 35 34 /** 36 * Get the pointer to the filename part of the name.37 *38 * @returns Pointer to where the filename starts within the string pointed to by pszFilename.39 * @returns Pointer to the terminator char if no filename.40 * @param pszFilename The filename to parse.41 */42 char *kHlpGetFilename(const char *pszFilename)43 {44 const char *pszLast = NULL;45 for (;;)46 {47 char ch = *pszFilename;48 #if defined(__OS2__) || defined(__WIN__)49 if (ch == '/' || ch == '\\' || ch == ':')50 {51 while ((ch = *++pszFilename) == '/' || ch == '\\' || ch == ':')52 /* nothing */;53 pszLast = pszFilename;54 }55 #else56 if (ch == '/')57 {58 while ((ch = *++pszFilename) == '/')59 /* betsuni */;60 pszLast = pszFilename;61 }62 #endif63 if (!ch)64 return (char *)(pszLast ? pszLast : pszFilename);65 pszFilename++;66 }67 }68 69 70 /**71 35 * Gets the filename suffix. 72 36 * … … 75 39 * @param pszFilename The filename to parse. 76 40 */ 77 char *kHlpGetSuff(const char *pszFilename)41 KHLP_DECL(char *) kHlpGetSuff(const char *pszFilename) 78 42 { 79 43 const char *pszDot = NULL; … … 103 67 * @param pszFilename The filename to parse. 104 68 */ 105 char *kHlpGetExt(const char *pszFilename)69 KHLP_DECL(char *) kHlpGetExt(const char *pszFilename) 106 70 { 107 71 char *psz = kHlpGetSuff(pszFilename); … … 109 73 } 110 74 111 112 /**113 * Checks if this is only a filename or if it contains any kind114 * of drive, directory, or server specs.115 *116 * @returns 1 if this is a filename only.117 * @returns 0 of it's isn't only a filename.118 * @param pszFilename The filename to parse.119 */120 int kHlpIsFilenameOnly(const char *pszFilename)121 {122 for (;;)123 {124 const char ch = *pszFilename++;125 #if defined(__OS2__) || defined(__WIN__)126 if (ch == '/' || ch == '\\' || ch == ':')127 #else128 if (ch == '/')129 #endif130 return 0;131 if (!ch)132 return 1;133 }134 }135 136 -
trunk/kStuff/kHlp/Generic/kHlpGetFilename.c
r3573 r3575 1 1 /* $Id$ */ 2 2 /** @file 3 * kHlpPath - kHlpGetFilename. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kLdr - The Dynamic Loader, Path Helper Functions.9 * This file is part of kStuff. 5 10 * 6 * Copyright (c) 2006-2007 knut st. osmundsen <bird-kbuild-src@anduin.net> 11 * kStuff is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLdr. 10 * 11 * kLdr is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLdr is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLdr; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kStuff; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ 26 27 26 28 27 /******************************************************************************* … … 40 39 * @param pszFilename The filename to parse. 41 40 */ 42 char *kHlpGetFilename(const char *pszFilename)41 KHLP_DECL(char *) kHlpGetFilename(const char *pszFilename) 43 42 { 44 43 const char *pszLast = NULL; … … 46 45 { 47 46 char ch = *pszFilename; 48 #if defined(__OS2__) || defined(__WIN__)47 #if K_OS == K_OS_OS2 || K_OS == K_OS_WINDOWS 49 48 if (ch == '/' || ch == '\\' || ch == ':') 50 49 { … … 67 66 } 68 67 69 70 /**71 * Gets the filename suffix.72 *73 * @returns Pointer to where the suffix starts within the string pointed to by pszFilename.74 * @returns Pointer to the terminator char if no suffix.75 * @param pszFilename The filename to parse.76 */77 char *kHlpGetSuff(const char *pszFilename)78 {79 const char *pszDot = NULL;80 pszFilename = kHlpGetFilename(pszFilename);81 for (;;)82 {83 char ch = *pszFilename;84 if (ch == '.')85 {86 while ((ch = *++pszFilename) == '.')87 /* nothing */;88 if (ch)89 pszDot = pszFilename - 1;90 }91 if (!ch)92 return (char *)(pszDot ? pszDot : pszFilename);93 pszFilename++;94 }95 }96 97 98 /**99 * Gets the filename extention.100 *101 * @returns Pointer to where the extension starts within the string pointed to by pszFilename.102 * @returns Pointer to the terminator char if no extension.103 * @param pszFilename The filename to parse.104 */105 char *kHlpGetExt(const char *pszFilename)106 {107 char *psz = kHlpGetSuff(pszFilename);108 return *psz ? psz + 1 : psz;109 }110 111 112 /**113 * Checks if this is only a filename or if it contains any kind114 * of drive, directory, or server specs.115 *116 * @returns 1 if this is a filename only.117 * @returns 0 of it's isn't only a filename.118 * @param pszFilename The filename to parse.119 */120 int kHlpIsFilenameOnly(const char *pszFilename)121 {122 for (;;)123 {124 const char ch = *pszFilename++;125 #if defined(__OS2__) || defined(__WIN__)126 if (ch == '/' || ch == '\\' || ch == ':')127 #else128 if (ch == '/')129 #endif130 return 0;131 if (!ch)132 return 1;133 }134 }135 136 -
trunk/kStuff/kHlp/Generic/kHlpIsFilenameOnly.c
r3573 r3575 1 1 /* $Id$ */ 2 2 /** @file 3 * kHlpPath - kHlpIsFilenameOnly. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kLdr - The Dynamic Loader, Path Helper Functions.9 * This file is part of kStuff. 5 10 * 6 * Copyright (c) 2006-2007 knut st. osmundsen <bird-kbuild-src@anduin.net> 11 * kStuff is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLdr. 10 * 11 * kLdr is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLdr is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLdr; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kStuff; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ 26 27 26 28 27 /******************************************************************************* … … 31 30 #include <k/kHlpPath.h> 32 31 #include <k/kHlpString.h> 33 34 35 /**36 * Get the pointer to the filename part of the name.37 *38 * @returns Pointer to where the filename starts within the string pointed to by pszFilename.39 * @returns Pointer to the terminator char if no filename.40 * @param pszFilename The filename to parse.41 */42 char *kHlpGetFilename(const char *pszFilename)43 {44 const char *pszLast = NULL;45 for (;;)46 {47 char ch = *pszFilename;48 #if defined(__OS2__) || defined(__WIN__)49 if (ch == '/' || ch == '\\' || ch == ':')50 {51 while ((ch = *++pszFilename) == '/' || ch == '\\' || ch == ':')52 /* nothing */;53 pszLast = pszFilename;54 }55 #else56 if (ch == '/')57 {58 while ((ch = *++pszFilename) == '/')59 /* betsuni */;60 pszLast = pszFilename;61 }62 #endif63 if (!ch)64 return (char *)(pszLast ? pszLast : pszFilename);65 pszFilename++;66 }67 }68 69 70 /**71 * Gets the filename suffix.72 *73 * @returns Pointer to where the suffix starts within the string pointed to by pszFilename.74 * @returns Pointer to the terminator char if no suffix.75 * @param pszFilename The filename to parse.76 */77 char *kHlpGetSuff(const char *pszFilename)78 {79 const char *pszDot = NULL;80 pszFilename = kHlpGetFilename(pszFilename);81 for (;;)82 {83 char ch = *pszFilename;84 if (ch == '.')85 {86 while ((ch = *++pszFilename) == '.')87 /* nothing */;88 if (ch)89 pszDot = pszFilename - 1;90 }91 if (!ch)92 return (char *)(pszDot ? pszDot : pszFilename);93 pszFilename++;94 }95 }96 97 98 /**99 * Gets the filename extention.100 *101 * @returns Pointer to where the extension starts within the string pointed to by pszFilename.102 * @returns Pointer to the terminator char if no extension.103 * @param pszFilename The filename to parse.104 */105 char *kHlpGetExt(const char *pszFilename)106 {107 char *psz = kHlpGetSuff(pszFilename);108 return *psz ? psz + 1 : psz;109 }110 32 111 33 … … 118 40 * @param pszFilename The filename to parse. 119 41 */ 120 intkHlpIsFilenameOnly(const char *pszFilename)42 KHLP_DECL(int) kHlpIsFilenameOnly(const char *pszFilename) 121 43 { 122 44 for (;;) 123 45 { 124 46 const char ch = *pszFilename++; 125 #if defined(__OS2__) || defined(__WIN__)47 #if K_OS == K_OS_OS2 || K_OS == K_OS_WINDOWS 126 48 if (ch == '/' || ch == '\\' || ch == ':') 127 49 #else … … 134 56 } 135 57 136 -
trunk/kStuff/kHlp/Generic/kHlpPage.c
r3573 r3575 29 29 *******************************************************************************/ 30 30 #include <k/kHlpAlloc.h> 31 #include <k/kHlpAssert.h> 31 32 32 33 #if K_OS == K_OS_OS2 … … 45 46 *******************************************************************************/ 46 47 #if K_OS == K_OS_OS2 47 /** The base of the stub object.48 /** The base of the loader stub object. <kLdr Hack> 48 49 * The OS/2 exe stub consists of a single data object. When allocating memory 49 * for an executable, we'll have to reuse this. 50 * for an executable, we'll have to reuse this. */ 50 51 static void *g_pvStub = NULL; 51 /** The size of the stub object - 0 if no stub. */52 /** The size of the stub object - 0 if no stub. <kLdr Hack> */ 52 53 static KSIZE g_cbStub = 0; 53 54 … … 213 214 * @param cb The byte count requested from kHlpPageAlloc(). 214 215 */ 215 KHLP_DECL(int) skHlpPageFree(void *pv, KSIZE cb)216 KHLP_DECL(int) kHlpPageFree(void *pv, KSIZE cb) 216 217 { 217 218 #if K_OS == K_OS_OS2
Note:
See TracChangeset
for help on using the changeset viewer.