Skip to content

Commit 18367ce

Browse files
committed
Ack, missed two files from the merge...looks like a .11 is goin gto have
to go out after all :(
1 parent b619cb0 commit 18367ce

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

src/backend/parser/sysfunc.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* sysfunc.c--
4+
* process system functions and return a string result
5+
*
6+
* Notes:
7+
* 1) I return a string result because most of the functions cannot return any
8+
* normal type anyway (e.g. SYS_DATE, SYS_TIME, etc...), and the few that
9+
* might (SYS_UID or whatever) can just return it as a string - no problem.
10+
* This keeps the function flexible enough to be of good use.
11+
*
12+
* Written by Chad Robinson, chadr@brttech.com
13+
* Last modified: 04/27/1996
14+
* -------------------------------------------------------------------------
15+
*/
16+
#include <stdio.h>
17+
#include <stdlib.h>
18+
#include <string.h>
19+
#include <time.h>
20+
21+
/*
22+
* Can't get much more obvious than this. Might need to replace localtime()
23+
* on older systems...
24+
*/
25+
char *Sysfunc_system_date(void)
26+
{
27+
time_t cur_time_secs;
28+
struct tm *cur_time_expanded;
29+
static char buf[12]; /* Just for safety, y'understand... */
30+
31+
time(&cur_time_secs);
32+
cur_time_expanded = localtime(&cur_time_secs);
33+
sprintf(buf, "%02.2d-%02.2d-%04.4d", cur_time_expanded->tm_mon+1,
34+
cur_time_expanded->tm_mday, cur_time_expanded->tm_year+1900);
35+
return &buf[0];
36+
}
37+
38+
char *SystemFunctionHandler(char *funct)
39+
{
40+
if (!strcmp(funct, "SYS_DATE"))
41+
return Sysfunc_system_date();
42+
return "*unknown function*";
43+
}
44+
45+
#ifdef SYSFUNC_TEST
46+
/*
47+
* Chad's rule of coding #4 - never delete a test function, even a stupid
48+
* one - you always need it 10 minutes after you delete it.
49+
*/
50+
void main(void)
51+
{
52+
printf("Current system date: %s\n", SystemFunctionHandler("SYS_DATE"));
53+
return;
54+
}
55+
#endif

src/backend/parser/sysfunc.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* sysfunc.h--
4+
* support for system functions
5+
*
6+
* -------------------------------------------------------------------------
7+
*/
8+
9+
extern char *SystemFunctionHandler(char *funct);
10+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy