Initial commit

This commit is contained in:
Paul Reeves 2023-01-20 13:00:07 +01:00
parent 16fa9fcc2a
commit 09c7298105
1 changed files with 95 additions and 0 deletions

95
src/MyFirstUDRKit.cpp Normal file
View File

@ -0,0 +1,95 @@
/*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* The Original Code was created by Adriano dos Santos Fernandes
* for the Firebird Open Source RDBMS project.
*
* Copyright (c) 2008 Adriano dos Santos Fernandes <adrianosf@gmail.com>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* Paul Reeves, 2023
*
*/
#define FB_UDR_STATUS_TYPE ::Firebird::ThrowStatusWrapper
#include <ibase.h>
#include <firebird/UdrCppEngine.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h>
#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <limits>
using namespace Firebird;
/*** DDL
create function flagged (
n1 integer,
n2 integer
) returns integer
external name 'my_first_udr_kit!MFK_flagged'
engine udr;
***/
FB_UDR_BEGIN_FUNCTION(MFK_flagged)
FB_UDR_MESSAGE(InMessage,
(FB_INTEGER, flags)
(FB_INTEGER, flag)
);
FB_UDR_MESSAGE(OutMessage,
(FB_INTEGER, result)
);
FB_UDR_EXECUTE_FUNCTION
{
if ( flags == NULL ) {
return 0;
}
ISC_UINT64 i = ( 1ULL << *flag );
return ( *flags & i ) ? 1 : 0;
}
FB_UDR_END_FUNCTION