Skip to content

Commit

Permalink
Merge branch 'TheAlgorithms:master' into mess-about
Browse files Browse the repository at this point in the history
  • Loading branch information
rbevin777 authored Sep 30, 2024
2 parents 1b49f54 + e5dad3f commit 3f3f6f7
Show file tree
Hide file tree
Showing 17 changed files with 576 additions and 86 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/awesome_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jobs:
uses: TheAlgorithms/scripts/formatter@main
with:
filetypes: .c,.h
- name: Update DIRECTORY.md
run: |
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
python3 build_directory_md.py C . .c,.h leetcode/ > DIRECTORY.md
git commit -m "updating DIRECTORY.md" DIRECTORY.md || true
- name: Get file changes
run: |
git branch
Expand All @@ -57,14 +52,14 @@ jobs:
needs: [MainSequence]
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
os: [windows-latest, ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: |
cmake -B ./build -S .
cmake --build build
cmake --build build --config Release
- name: Label on PR fail
uses: actions/github-script@v6
if: ${{ failure() && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' }}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/directory_writer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Directory writer
on:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
if: github.repository == 'TheAlgorithms/C' # We only need this to run in our repository.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build directory
uses: TheAlgorithms/scripts/directory_md@main
with:
language: C
working-directory: .
filetypes: .c,.h
ignored-directories: leetcode/,scripts/
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
cmake_minimum_required(VERSION 3.22)
project(Algorithms_in_C
LANGUAGES C
VERSION 1.0.0
DESCRIPTION "Set of algorithms implemented in C."
)
LANGUAGES C
VERSION 1.0.0
DESCRIPTION "Set of algorithms implemented in C."
)

# Set compilation standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED YES)

if(MSVC)
if (MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# add_compile_options(/Za)
endif(MSVC)
endif (MSVC)

# check for math library
# addresses a bug when linking on OSX
Expand Down
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* [Rot13](https://github.com/TheAlgorithms/C/blob/HEAD/cipher/rot13.c)

## Client Server
* [Bool](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/bool.h)
* [Client](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/client.c)
* [Fork](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/fork.h)
* [Remote Command Exec Udp Client](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/remote_command_exec_udp_client.c)
* [Remote Command Exec Udp Server](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/remote_command_exec_udp_server.c)
* [Server](https://github.com/TheAlgorithms/C/blob/HEAD/client_server/server.c)
Expand Down
24 changes: 15 additions & 9 deletions client_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ else()
CHECK_INCLUDE_FILE(arpa/inet.h ARPA_HEADERS)
endif()

include(CheckSymbolExists)
if(ARPA_HEADERS OR WINSOCK_HEADER)
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
# with full pathname. RELATIVE may makes it easier to extract an executable name
Expand All @@ -15,16 +16,21 @@ if(ARPA_HEADERS OR WINSOCK_HEADER)
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
foreach( testsourcefile ${APP_SOURCES} )
# I used a simple string replace, to cut off .cpp.
string( REPLACE ".c" "" testname ${testsourcefile} )
add_executable( ${testname} ${testsourcefile} )

if(OpenMP_C_FOUND)
target_link_libraries(${testname} PRIVATE OpenMP::OpenMP_C)
string(REPLACE ".c" "" testname ${testsourcefile})

if(NOT WIN32)
if(${testname} STREQUAL "fork" OR ${testname} STREQUAL "bool")
continue()
endif()
endif()
if(MATH_LIBRARY)
add_executable(${testname} ${testsourcefile})

if (OpenMP_C_FOUND)
target_link_libraries(${testname} PRIVATE OpenMP::OpenMP_C)
endif ()
if (MATH_LIBRARY)
target_link_libraries(${testname} PRIVATE ${MATH_LIBRARY})
endif()

endif ()
# if(HAS_UNISTD)
# target_compile_definitions(${testname} PRIVATE HAS_UNISTD)
# endif()
Expand All @@ -34,7 +40,7 @@ if(ARPA_HEADERS OR WINSOCK_HEADER)
# target_compile_definitions(${testname} PRIVATE WINSOCK_HEADER)
# endif()

if(WINSOCK_HEADER)
if (WINSOCK_HEADER)
target_link_libraries(${testname} PRIVATE ws2_32) # link winsock library on windows
endif()

Expand Down
55 changes: 55 additions & 0 deletions client_server/bool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2007 - INRIA
*
* Copyright (C) 2012 - 2016 - Scilab Enterprises
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* This file was originally licensed under the terms of the CeCILL v2.1,
* and continues to be available under such terms.
* For more information, see the COPYING file which you should have received
* along with this program.
*
*/
#ifndef __BOOL_H__
#define __BOOL_H__

/* define boolean type */
#ifdef BOOL
#undef BOOL
#endif

#ifdef TRUE
#undef TRUE
#endif

#ifdef FALSE
#undef FALSE
#endif


#ifndef _MSC_VER
typedef enum
{
FALSE = 0,
TRUE = 1
} BOOL;

#else
/* Please notice that BOOL is defined in <windef.h> */
/* BUT windef.h includes all others windows include */
/* it is better to redefine as */
typedef int BOOL;
#define FALSE 0
#define TRUE 1

#endif
/* converts BOOL to bool */
#define BOOLtobool(w) ((w != FALSE) ? true : false)

/* converts bool to BOOL */
#define booltoBOOL(w) ((w == true) ? TRUE : FALSE)

#endif /* __BOOL_H__ */
/*--------------------------------------------------------------------------*/
Loading

0 comments on commit 3f3f6f7

Please # to comment.