psp.c
来自「db.* (pronounced dee-be star) is an adva」· C语言 代码 · 共 272 行
C
272 行
/*************************************************************************** * * * db.* * * open source database kernel * * * * Copyright (c) 2000 Centura Software Corporation. All rights reserved. * * * * Use of this software, whether in source code format, or in executable, * * binary object code form, is governed by the CENTURA OPEN SOURCE LICENSE * * which is fully described in the LICENSE.TXT file, included within this * * distribution of source code files. * * * * Except as provided herein, the contents of this file are subject to the * * Centura Open Source Public License Version 1.0 (the "License"); you may * * not use this file except in compliance with the License. A copy of the * * License will be provided to you by Club ITTIA. * * * * Software distributed under the License is distributed on an "AS IS" * * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * * License for the specific language governing rights and limitations * * under the License. * * * * The Original Code is db.linux version 1.0, released February 29, 2000. * * * * The Initial Developer of the Original Code is Centura Software * * Corporation. Portions created by Centura Software Corporation are * * Copyright (C) 1984-2000 Centura Software Corporation. All Rights * * Reserved. * * * * This file contains modifications to the Original Code made by ITTIA. * * This file may only be used in accordance with the ITTIA DB.* V.2 * * License Agreement which is available at WWW.ITTIA.COM. * * * **************************************************************************//* psp.c - Contains generic routines of the PSP */#include "psp.h"#include "pspint.h"int psp_inited = 0;int psp_terminating = 0;/* =========================================================================== Initialize the PSP subsystem*/int psp_init( void){ if (psp_inited++ == 0) { if (psp_syncInit() != PSP_OKAY) { psp_inited = 0; return PSP_FAILED; } if (psp_memInit() != PSP_OKAY) { psp_syncTerm(); psp_inited = 0; return PSP_FAILED; } if (psp_fileInit() != PSP_OKAY) { psp_memTerm(); psp_syncTerm(); psp_inited = 0; return PSP_FAILED; } if (psp_osInit() != PSP_OKAY) { psp_fileTerm(); psp_memTerm(); psp_syncTerm(); psp_inited = 0; return PSP_FAILED; } } return PSP_OKAY;}/* =========================================================================== Shut down the PSP subsystem*/void psp_term( void){ if (psp_inited == 1) { psp_terminating = 1; psp_osTerm(); psp_fileTerm(); psp_syncShutdown(); psp_memTerm(); psp_syncTerm(); psp_inited = 0; } else psp_inited--;}#if defined(NEED_STRICMP)/* =========================================================================== Case insensitive comparison*/int stricmp( const char *s1, const char *s2){ int result; int c1; int c2; if (!s1) return s2 ? -1 : 0; if (!s2) return 1; do { c1 = (int) ((unsigned char) (islower(*s1) ? toupper(*s1) : *s1)); c2 = (int) ((unsigned char) (islower(*s2) ? toupper(*s2) : *s2)); result = c1 - c2; /* arithmetic over-/under-flow not possible */ s1++; s2++; } while (!result && c1 && c2); return result;}/* =========================================================================== Case insensitive comparison up to n bytes*/int strnicmp( const char *s1, const char *s2, size_t len){ int result; int c1; int c2; if (!s1) return s2 ? -1 : 0; if (!s2) return 1; for (result = 0; len > 0 && !result; s1++, s2++, len--) { c1 = (int) ((unsigned char) (islower(*s1) ? toupper(*s1) : *s1)); c2 = (int) ((unsigned char) (islower(*s2) ? toupper(*s2) : *s2)); result = c1 - c2; /* arithmetic over-/under-flow not possible */ } return result;}#endif#if defined(NEED_STRUPR)/* =========================================================================== Convert the string to upper case*/char *strupr( char *str){ register char *p; if (!str) return NULL; for (p = str; *p; p++) { if (islower(*p)) *p = (char) toupper(*p); } return str;}/* =========================================================================== Convert the string to lower case*/char *strlwr( char *str){ register char *p; if (!str) return NULL; for (p = str; *p; p++) { if (isupper(*p)) *p = (char) tolower(*p); } return str;}#endif#if defined(NEED_WCSICMP)int wcsicmp( const wchar_t *s1, const wchar_t *s2){ int result = 0; do { result = (int) towupper(*s1) - (int) towupper(*s2); } while (*s1++ && *s2++ && !result); return result;}int wcsnicmp( const wchar_t *s1, const wchar_t *s2, size_t len){ int result = 0; for ( ; len > 0 && !result; s1++, s2++, len--) { result = (int) towupper(*s1) - (int) towupper(*s2); if (!*s1 || !*s2) break; } return result;}#endif#if defined(NEED_WCSNCMP)int wcsncmp( const wchar_t *s1, const wchar_t *s2, size_t len){ int result = 0; for ( ; len > 0 && !result; s1++, s2++, len--) { result = (int) *s1 - (int) *s2; if (!*s1 || !*s2) break; } return result;}#endif#if defined(NEED_WCSNCPY)wchar_t * wcsncpy (wchar_t * to, const wchar_t * from, size_t size){ wchar_t * save_to = to; if (size > 0) { do { *to = *from; } while (size-- && *to++ && *from++);#if 0 while(size-- > 0) *to++ = 0;#endif } return save_to;}#endif#ifdef NEED_TOWUPPER/* ascii only approximation */wchar_t towupper(wchar_t ch){ return (ch < 0xff) ? toupper(ch) : ch;}#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?