Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 2.6)
project("outer project" C)
# Compile cmDIV.
try_compile(
compiled_div # result variable
${CMAKE_BINARY_DIR}/div # bindir
${CMAKE_SOURCE_DIR}/div # srcDir
div) # projectName
if(NOT compiled_div)
message(FATAL_ERROR "Failed to compile cmDIV")
endif()
# Load cmDIV.
load_command(DIV ${CMAKE_BINARY_DIR}/div)
if(NOT CMAKE_LOADED_COMMAND_DIV)
message(FATAL_ERROR "Failed to load cmDIV")
endif()
# Try div() command.
div(quot rem 2012 500)
message("
2012 / 500 = ${quot}
2012 % 500 = ${rem}
")

View file

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.6)
project(div C)
# Find cmCPluginAPI.h
include_directories(${CMAKE_ROOT}/include)
# Compile cmDIV from div-command.c
add_library(cmDIV MODULE div-command.c)

View file

@ -0,0 +1,55 @@
#include <cmCPluginAPI.h>
#include <stdio.h>
#include <stdlib.h>
static cmCAPI *api;
/*
* Respond to DIV(quotient remainder numerator denominator).
*/
static int
initial_pass(void *info, void *mf, int argc, char *argv[])
{
div_t answer;
int count, i, j, n[2];
char buf[512], c;
if (argc != 4) {
api->SetError(info, "Wrong number of arguments");
return 0; /* failure */
}
/* Parse numerator and denominator. */
for(i = 2, j = 0; i < 4; i++, j++) {
count = sscanf(argv[i], "%d%1s", &n[j], &c);
if (count != 1) {
snprintf(buf, sizeof buf,
"Not an integer: %s", argv[i]);
api->SetError(info, buf);
return 0; /* failure */
}
}
/* Call div(). */
if (n[1] == 0) {
api->SetError(info, "Division by zero");
return 0; /* failure */
}
answer = div(n[0], n[1]);
/* Set variables to answer. */
snprintf(buf, sizeof buf, "%d", answer.quot);
api->AddDefinition(mf, argv[0], buf);
snprintf(buf, sizeof buf, "%d", answer.rem);
api->AddDefinition(mf, argv[1], buf);
return 1; /* success */
}
CM_PLUGIN_EXPORT void
DIVInit(cmLoadedCommandInfo *info)
{
info->Name = "DIV";
info->InitialPass = initial_pass;
api = info->CAPI;
}