ssh
Embed:
(wiki syntax)
Show/hide line numbers
port.c
00001 /* port.c 00002 * 00003 * Copyright (C) 2014-2016 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSH. 00006 * 00007 * wolfSSH is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSH is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with wolfSSH. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 00022 /* 00023 * The port module wraps standard C library functions with macros to 00024 * cover portablility issues when building in environments that rename 00025 * those functions. This module also provides local versions of some 00026 * standard C library functions that are missing on some platforms. 00027 */ 00028 00029 00030 #ifdef HAVE_CONFIG_H 00031 #include <config.h> 00032 #endif 00033 00034 #include <stdio.h> 00035 #include <wolfssh/port.h> 00036 00037 00038 int wfopen(WFILE** f, const char* filename, const char* mode) 00039 { 00040 #ifdef USE_WINDOWS_API 00041 return fopen_s(f, filename, mode) != 0; 00042 #else 00043 if (f != NULL) { 00044 *f = fopen(filename, mode); 00045 return *f == NULL; 00046 } 00047 return 1; 00048 #endif 00049 } 00050 00051 00052 #ifndef WSTRING_USER 00053 00054 char* wstrnstr(const char* s1, const char* s2, unsigned int n) 00055 { 00056 unsigned int s2_len = (unsigned int)WSTRLEN(s2); 00057 00058 if (s2_len == 0) 00059 return (char*)s1; 00060 00061 while (n >= s2_len && s1[0]) { 00062 if (s1[0] == s2[0]) 00063 if (WMEMCMP(s1, s2, s2_len) == 0) 00064 return (char*)s1; 00065 s1++; 00066 n--; 00067 } 00068 00069 return NULL; 00070 } 00071 00072 #endif /* WSTRING_USER */
Generated on Tue Jul 12 2022 21:46:52 by 1.7.2