mm_util.c revision d1d2228c6cf3ec632d28262810ab7902932a5d33
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <fcntl.h>
#include <mms_list.h>
#include <mms_parser.h>
#include <mms_par_impl.h>
#include <libpq-fe.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <procfs.h>
#include <mms_trace.h>
#include <mms_strapp.h>
#include <netdb.h>
#include <strings.h>
#include <ctype.h>
#include <sys/resource.h>
#include <syslog.h>
#include <msg_sub.h>
#include <host_ident.h>
#include <mms_cfg.h>
#include "mm_db.h"
#include "mm.h"
#include "mm_sql.h"
#include "mm_commands.h"
#include "mm_util.h"
void
}
}
void
char *text;
ECLASS_INTERNAL, "ESYSTEM",
"text",
text,
NULL);
}
int
return (1);
}
char *
mms_par_node_t *work = 0;
int i = 0;
"response does not have a loctext clause");
return (NULL);
}
while (i < 2) {
"response does not have an arg "
"in the loctext clause");
return (NULL);
}
i ++;
}
return (loctext_arg->pn_string);
}
int
/* This function looks up a message id */
/* from the parse tree root */
/* if there is no message id, */
/* return -1 */
mms_par_node_t *work = 0;
int i = 0;
int message_id = -1;
MMS_PN_CLAUSE, 0)) == NULL) {
"response does not have an id clause");
return (-1);
}
while (i < 3) {
"response is missing an arg in the id clause");
return (-1);
}
i ++;
}
return (message_id);
} else {
"bad id in message id arguement");
return (-1);
}
}
char *
int message_id = 0;
char *local_text = NULL;
/*
* If there is a message,
* look up the id in the catalog,
* and create the loctext.
* If there is no matching id,
* use the id number and the
* loc text from the response
*/
"cmd->cmd_response is NULL,"
"no response found");
return (msg_rsp);
}
/* Get the id and loctext */
"response does not have a message id");
} else {
"message id is %d",
}
"response does not have a loctext");
} else {
"local text is %s",
}
if ((message_id == -1) &&
(local_text == NULL)) {
"there is no message in this response"
"msg_rsp == 'none'");
return (msg_rsp);
}
/* Check if the id is in the catalog */
if (mm_msg_exists(message_id) == 0) {
/* no catalog message found */
"id: %d",
if (local_text != NULL) {
" loctext: %s",
}
return (msg_rsp);
}
"mm_ret_response_msg: "
"internal error parsing message");
}
return (msg_rsp);
}
"error getting message from catalog");
return (msg_rsp);
}
void
/* If a child command had an error, */
/* we should include the message in this error response */
/* The error response should be in cmd->cmd_response */
NULL);
return;
}
/* Use this function to allocate mem space */
/* for any MMS command */
/* Sets up command for the given wka */
"Unable to malloc mm_command_t: %s",
return (NULL);
}
/* set initial values */
/* Zero ints */
mm_cmd->cmd_remove = 0;
mm_cmd->cmd_notify_to = 0;
mm_cmd->cmd_begin_has_end = 0;
mm_cmd->cmd_bufsize = 0;
mm_cmd->cmd_source_num = 0;
mm_cmd->cmd_dest_num = 0;
mm_cmd->cmd_const_num = 0;
mm_cmd->cmd_begin_has_end = 0;
mm_cmd->cmd_notify_to = 0;
/* char ptrs */
/* mount command info */
/* Create the source and dest lists */
/* Initalize the access mode list */
sizeof (cmi_mode_list_t),
/* initialize the cart list */
sizeof (cmi_cart_list_t),
/* Create Begin-end list */
/* Set Cmd->language */
}
}
}
} else {
/* Havent revieved a hello yet */
}
return (mm_cmd);
}
void
{
uuid_clear(uu);
/*
* Hit bugid 6397009 core dumped from get_ethernet_address() using
* uuid_generate(uu); so use uuid_generate_random(uu); instead.
*/
}
int
mm_is_fd_valid(int fd)
{
return (-1); /* failed, fd is invalid */
}
return (0); /* success, fd is valid */
}
int
mm_set_fd_limit(int fd_limit)
{
char buf[20];
return (1);
}
if (fd_limit == -1) {
} else {
}
/* wants to use system's open file descriptor max */
if (fd_limit == -1) {
return (0);
}
/* sanity check */
if (fd_limit < MM_FD_LIMIT_MIN) {
} else if (fd_limit > MM_FD_LIMIT_MAX) {
}
}
/* change the current limit */
/* don't exit. see that the limit is unchanged */
}
return (1);
}
return (0);
}
void
{
parm->mm_cbf_index = 0;
parm->mm_cbf_len = 0;
*result = 0;
} else {
*result = 1;
}
} else {
*result = 1;
}
}
char *
{
char *resp;
return (NULL);
}
"message [ id [ \"ieee\" \"1244\" \"5000\" ] "
"arguments [ "
"\"line\" \"%d\" "
"\"col\" \"%d\" "
"\"token\" \"%s\" "
"\"code\" \"%d\" "
"\"msg\" \"%s\" ] "
"loctext [ \"en\" \"line %d col %d "
return (resp);
}
{
int rc;
if (rc) {
"line %d col %d token %s code %d msg %s\n%s",
} else {
}
return (NULL);
}
return (cmd);
}
void
{
/* Response list */
int sent_one = 0;
int sent_count = 0;
sent_count ++;
sent_one = 1;
}
}
if (!sent_one) {
/* If there was not a response in the list */
/* check the cmd_buf and send */
"no response in list");
/* No response in the list */
/* send the cmd_buf */
"no resp in list, send cmd_buf");
}
}
}
void
{
int rc;
char ebuf[MMS_EBUF_LEN];
int len;
return;
} else {
}
}
void
{
int rc;
char ebuf[MMS_EBUF_LEN];
int len;
return;
} else {
}
}
int
{
char *text;
return (1);
}
MMS_PN_KEYWORD, NULL)) {
MMS_PN_KEYWORD, NULL)) {
MMS_PN_KEYWORD, NULL)) {
MMS_PN_CLAUSE, NULL)) {
MMS_PN_KEYWORD, &work)) {
}
MMS_PN_KEYWORD, &work)) {
}
}
/* TODO: response text and message clauses */
return (0);
}
/* get client connection hostname and ip mms_address from IPv4 or IPv6 */
int
{
int sa_len;
union {
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
} sa;
const int host_len = sizeof (mms_cli_host_t);
return (1);
}
return (1);
return (1);
}
return (1);
}
} else {
return (1);
}
return (1);
}
return (0);
}
/* get host from mm data as represented internally by mm */
char *
{
return (data->mm_host_ip);
}
/* get host from work area as represented internally by mm */
char *
{
}
/* get host from command as represented internally by mm */
char *
{
}
/* get host from cci as represented internally by mm */
char *
{
}
/* get host from string as represented internally by mm */
char *
mm_host_ident(char *host_str)
{
char *ident;
return (NULL);
}
return (strdup(ident));
}
void
{
char *value;
}
}
mm_read_trace_level(void)
{
char *value;
} else {
}
if (value)
return (severity);
}
void
{
char *level;
/*
* Reconcile file and database mms_trace level.
*/
"\"SYSTEM\";") != MM_DB_DATA) {
return;
}
return;
}
if (file_severity != db_severity) {
(void) mms_trace_filter(db_severity);
}
}
}
int
{
int limit;
/*
* Get the allowed number of open sockets from the database
*/
"\"SYSTEM\";") != MM_DB_DATA) {
limit = -1;
limit = -1;
} else {
}
limit = -1;
}
return (limit);
}
char *
int count = 0;
}
count ++;
}
return (NULL);
}
int
node =
return (1);
} else {
}
return (0);
}
void
cur);
}
}
int
node =
return (1);
} else {
}
return (0);
}
void
}
}
int
/* same */
return (1);
}
}
return (0);
}
int
int count = 0;
return (0);
}
}
return (1);
}
int
/* If the obj is already in the list, skip */
/* already have this obj */
return (1);
}
}
/* Don't have this obj yet */
mm_char_struct = (mm_char_list_t *)
if (mm_char_struct == NULL) {
"Unable to malloc mm_char_list_t: %s",
return (1);
}
return (0);
}
int
str) == 0) {
cmd->cmd_source_num ++;
return (0);
}
return (1);
}
int
if (mm_add_obj_list(dest_list,
str) == 0) {
cmd->cmd_dest_num ++;
return (0);
}
return (1);
}
int
str) == 0) {
cmd->cmd_const_num ++;
return (0);
}
return (1);
}