commit a2a440015dba67260796fa1604cf789ff2be478b Author: retoor Date: Thu Nov 28 18:39:34 2024 +0100 Initial commit diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..de7da58 --- /dev/null +++ b/.clang-format @@ -0,0 +1,192 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 140 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: BinPack +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentRequires: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 +PointerAlignment: Right +PPIndentWidth: -1 +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME +... + diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..ee4f0fe --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,16 @@ +name: isspam build +run-name: isspam build and memory check +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: apt update + - run: apt install build-essential valgrind make -y + - name: Check out repository code + uses: actions/checkout@v4 + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + - run: make valgrind diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9053540 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.history +.vscode diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8d73c7a --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +CC = gcc +CFLAGS = -Wall -Werror -Wextra -Ofast -std=c2x + +all: build run + +build: + @# removed -pedantic flag because it doesn't accept ' for formatting numbers + @# using printf + @$(CC) $(CFLAGS) isspam.c -o isspam + +run: run_spam wl run_not_spam + +format: + clang-format *.c *.h -i + +wl: + @echo "" + +run_spam: + @./isspam ./spam/*.txt + +run_not_spam: + @./isspam ./not_spam/*.txt + +valgrind: build + valgrind ./isspam ./spam/*.txt \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/isspam b/isspam new file mode 100755 index 0000000..bfde85c Binary files /dev/null and b/isspam differ diff --git a/isspam.c b/isspam.c new file mode 100644 index 0000000..3a7988d --- /dev/null +++ b/isspam.c @@ -0,0 +1,333 @@ +#include "rmalloc.h" +#include +#include +#include +#include + +#include "rstring_list.h" +#include "rstr.h" +#include + +#define sl rstring_list_t +#define slf rstring_list_free +#define sla rstring_list_add +#define sln rstring_list_new +#define rb rbuffer_t +#define rbf rbuffer_free +#define rbs rbuffer_to_string +#define rbw rbuffer_write +#define rbn rbuffer_new + +char *forbidden_words[] = { + "recovery", "techie", "http", "https", "digital", "hack", "::", "//", "com", + "@", "crypto", "bitcoin", "wallet", "hacker", "welcome", "whatsapp", "email", "cryptocurrency", + "stolen", "freeze", "quick", "crucial", "tracing", "scammers", "expers", "hire", "century", + "transaction", "essential", "managing", "contact", "contacting", "understanding", "assets", "funds", NULL}; + +void sld(sl *lst) { + for (uint i = 0; i < lst->count; i++) { + printf("<%u:%s>\n", i, lst->strings[i]); + } +} + +char *remove_preserved_chars(char *content) { + char *cc = (char *)malloc(strlen(content) + 1); + *cc = 0; + char *ccp = cc; + while (*content) { + if (*content == '<' || *content == '>' || *content == ':') { + content++; + continue; + } + *ccp = *content; + ccp++; + *ccp = 0; + content++; + } + return cc; +} + +char *slds(sl *lst) { + str_t *buffer = strn(1337); + for (uint i = 0; i < lst->count; i++) { + char *temp = (char *)malloc(strlen(lst->strings[i]) + 20); + char *cc = remove_preserved_chars(lst->strings[i]); + sprintf(temp, "<%u:%s>\n", i, cc); + free(cc); + stra(buffer, temp); + free(temp); + } + return strc(buffer); +} + +bool isws(char c) { return c == '\t' || c == '\n' || c == ' ' || c == ','; } + +char *stripws(char *content) { + char *cc = (char *)malloc(strlen(content) + 1); + *cc = 0; + char *ccp = cc; + while (*content) { + if (!isws(*content)) { + *ccp = *content; + ccp++; + *ccp = 0; + } + content++; + } + return cc; +} + +char *fread_till_eof(FILE *f) { + char c; + str_t *buffer = strn(1337); + while ((c = fgetc(f)) != EOF) { + strac(buffer, c); + } + char *content = strc(buffer); + return content; +} + +rstring_list_t *get_sentences(char *content) { + + rstring_list_t *sentences = rstring_list_new(); + char *sentence_buffer = (char *)malloc(strlen(content) + 1); + char *sentence_buffer_p = sentence_buffer; + // rbuffer_t * buffer = rbuffer_new(NULL,0); + bool in_line = false; + while (*content) { + if ((*content == ' ' || *content == '\t' || *content == '\n') && !in_line) { + content++; + continue; + } else { + in_line = true; + } + if (*content == '.') { + *sentence_buffer_p = *content; + sentence_buffer_p++; + *sentence_buffer_p = 0; + rstring_list_add(sentences, sentence_buffer); + sentence_buffer_p = sentence_buffer; + *sentence_buffer = 0; + content++; + in_line = false; + continue; + } + *sentence_buffer_p = *content; + sentence_buffer_p++; + *sentence_buffer_p = 0; + content++; + } + free(sentence_buffer); + return sentences; +} + +rstring_list_t *get_words(char *content) { + rstring_list_t *words = rstring_list_new(); + char *word_buffer = (char *)malloc(strlen(content) + 1); + char *word_buffer_p = word_buffer; + *word_buffer_p = 0; + // rbuffer_t * buffer = rbuffer_new(NULL,0); + while (*content) { + if (*content == ' ' || *content == '\t' || *content == '\n') { + if (word_buffer_p != word_buffer) { + rstring_list_add(words, word_buffer); + word_buffer_p = word_buffer; + *word_buffer = 0; + } + content++; + continue; + } + *word_buffer_p = *content; + word_buffer_p++; + *word_buffer_p = 0; + content++; + } + free(word_buffer); + return words; +} + +bool is_fully_capitalized_word(char *word) { + while (*word) { + if (isalnum(*word) && toupper(*word) != *word) + return false; + word++; + } + return true; +} + +sl *get_capitalized_words(char *content) { + sl *capitalized_words = sln(); + sl *sentences = get_sentences(content); + for (uint j = 0; j < sentences->count; j++) { + char *sentence = sentences->strings[j]; + sl *all_words = get_words(sentence); + + // Always skip the first word since sentences start with + for (uint i = 0; i < all_words->count; i++) { + if (is_fully_capitalized_word(all_words->strings[i])) { + rstring_list_add(capitalized_words, all_words->strings[i]); + } + } + slf(all_words); + } + slf(sentences); + return capitalized_words; +} + +char *clean_content(char *content) { + char *allowed_ichars = "01234567891abcdefghijklmnopqrstuvwxyz \n.,!?"; + char *clean_content = (char *)malloc(strlen(content) + 1); + char *clean_content_p = clean_content; + *clean_content_p = 0; + while (*content) { + if (strchr(allowed_ichars, tolower(*content))) { + *clean_content_p = *content; + clean_content_p++; + *clean_content_p = 0; + } + content++; + } + return clean_content; +} + +sl *get_numbers(char *content) { + char *cc = clean_content(content); + char *ccc = stripws(cc); + char *cccp = ccc; + free(cc); + char *number_buffer = (char *)malloc(strlen(ccc) + 1); + *number_buffer = 0; + char *number_buffer_p = number_buffer; + sl *numbers = sln(); + while (*cccp) { + if (isdigit((*cccp))) { + *number_buffer_p = *cccp; + number_buffer_p++; + *number_buffer_p = 0; + } else if (number_buffer != number_buffer_p) { + sla(numbers, number_buffer); + *number_buffer = 0; + number_buffer_p = number_buffer; + } + cccp++; + } + free(number_buffer); + free(ccc); + return numbers; +} + +bool stricmp(char *word1, char *word2) { + while (*word1 && tolower(*word1) == tolower(*word2)) { + word1++; + word2++; + } + return *word1 == *word2; +} + +bool containswordi(sl *words, char *word) { + for (uint i = 0; i < words->count; i++) { + if (stricmp(words->strings[i], word)) + return true; + } + return false; +} + +sl *get_forbidden_words(char *content) { + sl *words = get_words(content); + sl *found = sln(); + for (int j = 0; forbidden_words[j] != NULL; j++) { + if (containswordi(words, forbidden_words[j])) { + rstring_list_add(found, forbidden_words[j]); + } + } + + slf(words); + return found; +} + +void analyze(FILE *f) { + char *data = fread_till_eof(f); + + str_t *all = strn(1337); + char *sbuf = NULL; + + char *clean_data = clean_content(data); + + free(clean_data); + + // All capitalized words + sl *capitalized_words = get_capitalized_words(data); + uint capitalized_words_count = capitalized_words->count; + printf("Capitalized words: %u\n", capitalized_words_count); + sbuf = slds(capitalized_words); + stra(all, sbuf); + free(sbuf); + + sl *sentences = get_sentences(data); + + // All sentences + printf("Sentences: %u\n", sentences->count); + // sld(sentences); + sbuf = slds(sentences); + stra(all, sbuf); + free(sbuf); + + sl *words = get_words(data); + + // All words + printf("Words: %u\n", words->count); + // sld(words); + sbuf = slds(words); + stra(all, sbuf); + free(sbuf); + + // Numbers + sl *numbers = get_numbers(data); + printf("Numbers: %u\n", numbers->count); + // sld(numbers); + sbuf = slds(numbers); + stra(all, sbuf); + free(sbuf); + + // Forbidden words + sl *fw = get_forbidden_words(data); + printf("Forbidden words: %u\n", fw->count); + // sld(fw); + sbuf = slds(fw); + stra(all, sbuf); + free(sbuf); + + strd(all); + uint word_count_per_sentence = words->count / sentences->count; + printf("Word count per sentence: %u\n", word_count_per_sentence); + + slf(capitalized_words); + slf(sentences); + slf(words); + slf(numbers); + slf(fw); + + free(data); +} + +void analyze_file(char *path) { + FILE *f = fopen(path, "r"); + analyze(f); + fclose(f); +} + +int main(int argc, char *argv[]) { + + if (argc > 1) { + for (int i = 1; i < argc; i++) { + printf("File: %s\n", argv[i]); + analyze_file(argv[i]); + printf("\n"); + } + printf("%s\n", rmalloc_stats()); + return 0; + } + analyze(stdin); + printf("%s\n", rmalloc_stats()); + return 0; +} \ No newline at end of file diff --git a/not_spam/correct1.txt b/not_spam/correct1.txt new file mode 100644 index 0000000..4b72bb7 --- /dev/null +++ b/not_spam/correct1.txt @@ -0,0 +1 @@ +I am Nastya and downvoted this post because post is considered spam. Your message will be removed from this community site due too much downvotes. See my profile for more information. Read my source code mentioned on my profile to see what you did wrong. Should be no problem for a developer. diff --git a/rmalloc.h b/rmalloc.h new file mode 100644 index 0000000..dd653a7 --- /dev/null +++ b/rmalloc.h @@ -0,0 +1,220 @@ +// RETOOR - Nov 28 2024 +#ifndef RMALLOC_H +#define RMALLOC_H +#ifndef RMALLOC_OVERRIDE +#define RMALLOC_OVERRIDE 1 +#endif +#ifdef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE_TEMP _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif +#ifndef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112L +#endif +#ifndef ulonglong +#define ulonglong unsigned long long +#endif +#include +#include +#include +#include +#ifndef RTEMP_H +#define RTEMP_H + +#ifndef RTYPES_H +#define RTYPES_H +#ifdef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE_TEMP _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif +#ifndef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112L +#endif +#include +#include // uint +#include +#include // ulong +#ifndef ulonglong +#define ulonglong unsigned long long +#endif +#ifndef uint +typedef unsigned int uint; +#endif +#ifndef byte +typedef unsigned char byte; +#endif +#ifdef _POSIX_C_SOURCE_TEMP +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE _POSIX_C_SOURCE_TEMP +#undef _POSIX_C_SOURCE_TEMP +#else +#undef _POSIX_C_SOURCE +#endif +#endif + +#include +#ifndef RTEMPC_SLOT_COUNT +#define RTEMPC_SLOT_COUNT 20 +#endif +#ifndef RTEMPC_SLOT_SIZE +#define RTEMPC_SLOT_SIZE 1024 * 64 * 128 +#endif + +bool _rtempc_initialized = false; +pthread_mutex_t _rtempc_thread_lock; +bool rtempc_use_mutex = true; +byte _current_rtempc_slot = 1; +char _rtempc_buffer[RTEMPC_SLOT_COUNT][RTEMPC_SLOT_SIZE]; +char *rtempc(char *data) { + + if (rtempc_use_mutex) { + if (!_rtempc_initialized) { + _rtempc_initialized = true; + pthread_mutex_init(&_rtempc_thread_lock, NULL); + } + + pthread_mutex_lock(&_rtempc_thread_lock); + } + + uint current_rtempc_slot = _current_rtempc_slot; + _rtempc_buffer[current_rtempc_slot][0] = 0; + strcpy(_rtempc_buffer[current_rtempc_slot], data); + _current_rtempc_slot++; + if (_current_rtempc_slot == RTEMPC_SLOT_COUNT) { + _current_rtempc_slot = 0; + } + if (rtempc_use_mutex) + pthread_mutex_unlock(&_rtempc_thread_lock); + return _rtempc_buffer[current_rtempc_slot]; +} + +#define sstring(_pname, _psize) \ + static char _##_pname[_psize]; \ + _##_pname[0] = 0; \ + char *_pname = _##_pname; + +#define string(_pname, _psize) \ + char _##_pname[_psize]; \ + _##_pname[0] = 0; \ + char *_pname = _##_pname; + +#define sreset(_pname, _psize) _pname = _##_pname; +#define sbuf(val) rtempc(val) +#endif +#ifdef _POSIX_C_SOURCE_TEMP +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE _POSIX_C_SOURCE_TEMP +#undef _POSIX_C_SOURCE_TEMP +#else +#undef _POSIX_C_SOURCE +#endif + +ulonglong rmalloc_count = 0; +ulonglong rmalloc_alloc_count = 0; +ulonglong rmalloc_free_count = 0; +ulonglong rmalloc_total_bytes_allocated = 0; +void *_rmalloc_prev_realloc_obj = NULL; +size_t _rmalloc_prev_realloc_obj_size = 0; + +void *rmalloc(size_t size) { + void *result; + while (!(result = malloc(size))) { + fprintf(stderr, "Warning: malloc failed, trying again.\n"); + } + rmalloc_count++; + rmalloc_alloc_count++; + rmalloc_total_bytes_allocated += size; + return result; +} +void *rcalloc(size_t count, size_t size) { + void *result; + while (!(result = calloc(count, size))) { + fprintf(stderr, "Warning: calloc failed, trying again.\n"); + } + rmalloc_alloc_count++; + rmalloc_count++; + rmalloc_total_bytes_allocated += count * size; + return result; +} +void *rrealloc(void *obj, size_t size) { + if (!obj) { + rmalloc_count++; + } + rmalloc_alloc_count++; + if (obj == _rmalloc_prev_realloc_obj) { + rmalloc_total_bytes_allocated += size - _rmalloc_prev_realloc_obj_size; + _rmalloc_prev_realloc_obj_size = size - _rmalloc_prev_realloc_obj_size; + } else { + _rmalloc_prev_realloc_obj_size = size; + } + void *result; + while (!(result = realloc(obj, size))) { + fprintf(stderr, "Warning: realloc failed, trying again.\n"); + } + _rmalloc_prev_realloc_obj = result; + return result; +} + +char *rstrdup(const char *s) { + if (!s) + return NULL; + char *result; + size_t size = strlen(s) + 1; + result = rmalloc(size); + memcpy(result, s, size); + rmalloc_total_bytes_allocated += size; + return result; +} +void *rfree(void *obj) { + rmalloc_count--; + rmalloc_free_count++; + free(obj); + return NULL; +} + +#if RMALLOC_OVERRIDE +#define malloc rmalloc +#define calloc rcalloc +#define realloc rrealloc +#define free rfree +#define strdup rstrdup +#endif + +char *rmalloc_lld_format(ulonglong num) { + char res[100]; + res[0] = 0; + sprintf(res, "%'lld", num); + char *resp = res; + while (*resp) { + if (*resp == ',') + *resp = '.'; + resp++; + } + return sbuf(res); +} + + +char *rmalloc_bytes_format(int factor, ulonglong num) { + char *sizes[] = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; + if (num > 1024) { + return rmalloc_bytes_format(factor + 1, num / 1024); + } + char res[100]; + res[0] = 0; + sprintf(res, "%s %s", rmalloc_lld_format(num), sizes[factor]); + return sbuf(res); +} + +char *rmalloc_stats() { + static char res[200]; + res[0] = 0; + setlocale(LC_NUMERIC, "en_US.UTF-8"); + sprintf(res, "Memory usage: %s, %s (re)allocated, %s unqiue free'd, %s in use.", rmalloc_bytes_format(0, rmalloc_total_bytes_allocated), + rmalloc_lld_format(rmalloc_alloc_count), rmalloc_lld_format(rmalloc_free_count), rmalloc_lld_format(rmalloc_count)); + setlocale(LC_NUMERIC, ""); + return res; +} + +#endif diff --git a/rstr.h b/rstr.h new file mode 100644 index 0000000..9ae9c72 --- /dev/null +++ b/rstr.h @@ -0,0 +1,52 @@ +#ifndef RSTR_H +#define RSTR_H +#include +#include +#include + +typedef struct str_t { + char *content; + size_t length; + size_t buffer_size; + size_t size; +} str_t; + +str_t *strn(size_t buffer_size) { + str_t *result = (str_t *)malloc(sizeof(str_t)); + result->length = 0; + result->size = buffer_size; + result->buffer_size = buffer_size; + result->content = (char *)malloc(buffer_size); + result->content[0] = 0; + return result; +} +void stra(str_t *str, const char *to_append) { + size_t required_new_length = str->length + strlen(to_append) + 1; + str->length += strlen(to_append); + if (required_new_length > str->size) { + str->size += required_new_length + str->buffer_size; + str->content = (char *)realloc(str->content, str->size + 1); + } else { + // printf("NO NDEED\n"); + } + strcat(str->content, to_append); + str->content[str->length] = 0; +} +void strac(str_t *str, const char c) { + char to_append[] = {c, 0}; + stra(str, to_append); +} +void strd(str_t *str) { + if (str->content) { + free(str->content); + } + free(str); +} +char *strc(str_t *str) { + char *content = str->content; + str->content = NULL; + strd(str); + return content; +} + +#endif \ No newline at end of file diff --git a/rstring_list.h b/rstring_list.h new file mode 100644 index 0000000..c3f71d5 --- /dev/null +++ b/rstring_list.h @@ -0,0 +1,44 @@ +#ifndef RSTRING_LIST_H +#define RSTRING_LIST_H +#include +#include +#include + +typedef struct rstring_list_t { + unsigned int size; + unsigned int count; + char **strings; +} rstring_list_t; + +rstring_list_t *rstring_list_new() { + rstring_list_t *rsl = (rstring_list_t *)malloc(sizeof(rstring_list_t)); + memset(rsl, 0, sizeof(rstring_list_t)); + return rsl; +} + +void rstring_list_free(rstring_list_t *rsl) { + for (uint i = 0; i < rsl->size; i++) { + free(rsl->strings[i]); + } + if (rsl->strings) + free(rsl->strings); + free(rsl); +} + +void rstring_list_add(rstring_list_t *rsl, char *str) { + if (rsl->count == rsl->size) { + rsl->size++; + rsl->strings = (char **)realloc(rsl->strings, sizeof(char *) * rsl->size); + } + rsl->strings[rsl->count] = strdup(str); + rsl->count++; +} +bool rstring_list_contains(rstring_list_t *rsl, char *str) { + for (uint i = 0; i < rsl->count; i++) { + if (!strcmp(rsl->strings[i], str)) + return true; + } + return false; +} + +#endif diff --git a/spam/examole_spam3.txt b/spam/examole_spam3.txt new file mode 100644 index 0000000..0b4c967 --- /dev/null +++ b/spam/examole_spam3.txt @@ -0,0 +1,7 @@ +TESTED CRYPTOCURRENCY RECOVERY SERVICE \\ DIGITAL HACK RECOVERY + +When the devastating reality of lost or stolen Bitcoin strikes, the path to recovery can seem bleak and hopeless. However, the story of DIGITAL HACK RECOVERY stands as a shining beacon of hope, demonstrating the power of perseverance in the face of seemingly insurmountable odds. This specialized service, founded by a team of tenacious experts, has made it their mission to reunite people with their rightful digital assets, no matter how complex or convoluted the situation may be. Through their unwavering dedication and meticulous investigative techniques, DIGITAL HACK RECOVERY has time and again succeeded in tracking down lost Bitcoin, navigating the labyrinthine world of blockchain technology and leveraging their deep understanding of crypto ecosystems. Their success stories are a testament to the resilience of the human spirit, as they've helped individuals regain access to life-changing sums of money that had been presumed lost forever. In an industry rife with uncertainty and risk, DIGITAL HACK RECOVERY has emerged as a trusted ally, guiding clients through the darkness with a steadfast commitment to recovery. By combining cutting-edge digital forensics, strategic partnerships, and a relentless determination to leave no stone unturned, this remarkable organization has earned the gratitude of countless individuals who had resigned themselves to the permanent disappearance of their hard-earned Bitcoin. In a world where the digital landscape can feel overwhelming and unpredictable, DIGITAL HACK RECOVERY stands as a shining example of what can be achieved through perseverance, expertise, and an unwavering belief in the possibility of redemption. I tried everything I could think of. I contacted support forums, tried password recovery tools, scoured Reddit for advice, and spent countless hours following step-by-step guides. Every lead I followed seemed to end in disappointment. I felt like I was chasing an illusion—getting closer, but never quite reaching it. With every attempt that failed, my hope dwindled further. It was an overwhelming feeling, knowing that I had lost something irreplaceable, something I had worked so hard for, and worse—something I had no way of recovering. Months passed, and I was ready to give up. I had accepted that my Bitcoin was gone, lost forever. But that feeling of helplessness lingered, gnawing at me in the back of my mind but DIGITAL HACK RECOVERY made the change of my life when I got the news of the recovery. Thank you very much. Contact them via contact details bellow⁚ + +Email; digital hack recovery @ techie . com +WhatsApp +19152151930 +Website; https : // digital hack recovery . com \ No newline at end of file diff --git a/spam/example_spam.txt b/spam/example_spam.txt new file mode 100644 index 0000000..473d30c --- /dev/null +++ b/spam/example_spam.txt @@ -0,0 +1,20 @@ +HIRE Century Web Recovery TO RECOVER YOUR LOST BITCOIN + +If you’ve lost your Bitcoin to an online scam, hiring a professional recovery service can significantly improve your chances of getting your funds back. Century Web Recovery specializes in Bitcoin recovery, helping victims reclaim their stolen assets. Here’s what you need to know: + +Understanding the Recovery Process +The recovery process begins with contacting Century Web Recovery. Their team will guide you through the steps necessary to initiate an investigation into your case. Understanding the process is key to managing your expectations. + +Documenting Your Case +To facilitate recovery, it’s essential to document all relevant information regarding the scam. This includes transaction records, wallet addresses, and any communications with the scammer. Century Web Recovery will help you gather this information to build a strong case. + +Investigation and Tracking +Once you hire Century Web Recovery, their experts will begin investigating your case. They use sophisticated tools to track the stolen Bitcoin, identifying the paths taken by the scammers. This tracing is crucial for successful recovery. + +Freezing Stolen Assets +Quick action is vital in recovering stolen Bitcoin.Century Web Recovery works directly with cryptocurrency exchanges to freeze any stolen assets, preventing the scammers from cashing out your funds. This collaboration is essential for a successful recovery. + +Legal Support and Guidance +If necessary, Century Web Recovery can provide legal support. They will guide you on reporting the scam to law enforcement and assist in filing any legal claims. Their expertise in crypto-related cases ensures you receive the best advice on how to proceed. + +If you’ve lost Bitcoin to an online scam, don’t hesitate. Hire Century Web Recovery to recover your lost assets and regain your financial security. \ No newline at end of file diff --git a/spam/example_spam2.txt b/spam/example_spam2.txt new file mode 100644 index 0000000..b21952e --- /dev/null +++ b/spam/example_spam2.txt @@ -0,0 +1,3 @@ +Email; digital hack recovery @ techie . com +WhatsApp +19152151930 +Website; https : // digital hack recovery . com \ No newline at end of file