Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rmqplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
WASD
rmqplus
Commits
5d66344b352a
Commit
5d66344b352a
authored
4 years ago
by
jfp
Browse files
Options
Downloads
Patches
Plain Diff
rmqplus.c initial version
parent
554bd3733670
Branches
Branches containing commit
No related tags found
1 merge request
!1
rmqplus.c initial version
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
rmqplus.c
+154
-0
154 additions, 0 deletions
rmqplus.c
with
154 additions
and
0 deletions
rmqplus.c
0 → 100644
+
154
−
0
View file @
5d66344b
/*****************************************************************************/
/*
This program is used in CGIplus environment.
Generate a json with all variables, RPC call using RabbitMQ
then return the result.
Use part of CGIplusDemo.c
This program to use 'struct' mode for passing the CGIplus variables.
VERSION HISTORY (update SOFTWAREVN as well!)
---------------
01-SEP-2020 JFP v1.0.0, initial development
*/
/*****************************************************************************/
#define SOFTWAREVN "1.0.0"
#define SOFTWARENM "RMQPLUS"
#if defined(__ALPHA)
#define SOFTWAREID SOFTWARENM " AXP-" SOFTWAREVN
#elif defined(__ia64)
#define SOFTWAREID SOFTWARENM " IA64-" SOFTWAREVN
#elif defined(__VAX)
#define SOFTWAREID SOFTWARENM " VAX-" SOFTWAREVN
#else
#define SOFTWAREID SOFTWARENM " UNKNOWN-" SOFTWAREVN
#endif
#ifndef __VAX
#pragma nomember_alignment
#endif
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<ctype.h>
#include
<errno.h>
#include
<time.h>
#include
<ssdef.h>
#include
<cgilib.h>
#include
<cJSON.h>
#include
<amqp_tcp_socket.h>
#include
<amqp.h>
#include
<amqp_framing.h>
char
Utility
[]
=
"RMQPLUS"
;
int
Debug
,
IsCgiPlus
,
UsageCounter
;
char
*
CgiPlusEofPtr
;
char
FirstUsedDateTime
[
32
],
NowDateTime
[
32
];
unsigned
long
UnixTime
;
struct
tm
*
UnixTmPtr
;
int
rmqplus
();
/*
* Main routine, just use an infinite loop calling rmqplus
*/
main
()
{
/*********/
/* begin */
/*********/
if
(
getenv
(
"RMQPLUS$DBUG"
))
Debug
=
1
;
CgiLibEnvironmentSetDebug
(
Debug
);
time
(
&
UnixTime
);
UnixTmPtr
=
localtime
(
&
UnixTime
);
if
(
!
strftime
(
FirstUsedDateTime
,
sizeof
(
FirstUsedDateTime
),
"%a, %d %b %Y %T"
,
UnixTmPtr
))
strcpy
(
FirstUsedDateTime
,
"[error]"
);
for
(;;)
{
int
s
;
time
(
&
UnixTime
);
UnixTmPtr
=
localtime
(
&
UnixTime
);
if
(
!
strftime
(
NowDateTime
,
sizeof
(
NowDateTime
),
"%a, %d %b %Y %T"
,
UnixTmPtr
))
strcpy
(
NowDateTime
,
"[error]"
);
/* wait for the next request */
CgiLibVar
(
""
);
s
=
rmqplus
();
CgiLibCgiPlusEOF
();
}
exit
(
SS
$
_NORMAL
);
}
/*
*
*/
static
cJSON
*
cjson_create_root
(
void
)
{
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
obj
;
obj
=
cJSON_AddObjectToObject
(
root
,
"in"
);
obj
=
cJSON_AddObjectToObject
(
root
,
"out"
);
return
root
;
}
int
rmqplus
()
{
cJSON
*
cjson_root
,
*
cjson_in
,
*
cjson_out
;
char
*
cptr
,
*
cname
,
*
cvalue
;
/*********/
/* begin */
/*********/
if
(
Debug
)
fprintf
(
stdout
,
"rmqplus()
\n
"
);
cjson_root
=
cjson_create_root
();
cjson_in
=
cJSON_GetObjectItem
(
cjson_root
,
"in"
);
cjson_out
=
cJSON_GetObjectItem
(
cjson_root
,
"out"
);
fprintf
(
stdout
,
"Content-Type: application/json
\n
\
Expires: Thu, 01 Jan 1970 00:00:01 GMT
\n
\
\n
\
"
);
/* list all CGIplus variables names and values one-by-one */
while
(
cptr
=
CgiLibVar
(
"*"
))
{
cname
=
cptr
;
cvalue
=
strchr
(
cptr
,
'='
);
if
(
cvalue
)
{
*
cvalue
=
'\0'
;
++
cvalue
;
if
(
!
cJSON_AddItemToObject
(
cjson_in
,
cname
,
cJSON_CreateString
(
cvalue
)))
{
cJSON_Delete
(
cjson_root
);
fputs
(
"{
\"
status
\"
: 0}
\n
"
,
stdout
);
return
(
0
);
}
}
}
fputs
(
cJSON_PrintUnformatted
(
cjson_root
),
stdout
);
fputs
(
"
\n
"
,
stdout
);
cJSON_Delete
(
cjson_root
);
return
(
1
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment