📄 my_string.c
字号:
/*
MikroTik PPPoE - MikroTik PPP over Ethernet client for Windows
Copyright (C), 2001 MikroTikls
The contents of this program are subject to the Mozilla Public License
Version 1.1; you may not use this program except in compliance with the
License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
http://www.mikrotik.com
mt@mt.lv
*/
#include "my_string.h"
#include "main.h"
int MyMemCmp(PVOID p1, PVOID p2, UINT len) {
UINT i;
PUCHAR c1 = (PUCHAR)p1;
PUCHAR c2 = (PUCHAR)p2;
for (i = 0; i < len; i++) {
if (*c1 != *c2) return 1;
++c1;
++c2;
}
return 0;
}
int StrLen(PUCHAR str) {
int len = 0;
while(str[len]) len++;
return len;
}
int StrNCmp(PUCHAR str1, PUCHAR str2, int char_count) {
int a;
for(a = 0; a < char_count; a++) {
if(str1[a] != str2[a]) {
return 0;
}
}
return 1;
}
int ReplaceString(PUCHAR str, PUCHAR keyword) {
return 1;
}
int HasSubstring(PUCHAR str, PUCHAR keyword) {
int str_len = StrLen(str);
int key_len = StrLen(keyword);
int run_len = str_len - key_len;
int curr_pos = 0;
if(run_len < 0)
return 0;
do {
curr_pos++;
} while (curr_pos < run_len);
return 0;
}
void CopyUnicodeStr(PNDIS_STRING str, char* buf) {
int len = 0;
while((len < str->Length) && (str->Buffer[len] != 0)) {
buf[len] = str->Buffer[len] & 0xff;
len++;
}
buf[len] = 0;
}
void PrintUnicodeStr(PNDIS_STRING str) {
int len = 0;
while((len < str->Length) && (str->Buffer[len] != 0)) {
DbgPrint("%c", str->Buffer[len] & 0xff);
len++;
}
}
void UnicodeFromWideBuffer(PNDIS_STRING str, WCHAR *buf) {
WCHAR *b = buf;
NDIS_STATUS s;
str->Length = 0;
while (*b != 0) {
++b;
++str->Length;
}
str->Length *= 2;
s = NdisAllocateMemory(&str->Buffer, str->Length + 2, 0, MaxAddress);
if (s != NDIS_STATUS_SUCCESS) {
str->Length = 0;
str->MaximumLength = 0;
str->Buffer = NULL;
}
else {
NdisMoveMemory(str->Buffer, buf, str->Length + 2);
str->MaximumLength = str->Length + 2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -