1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/global.h>
21
#include "libdrizzle_priv.h"
23
#include "libdrizzle.h"
34
#include <sys/socket.h>
35
#include <netinet/in.h>
36
#include <arpa/inet.h>
41
#ifdef HAVE_SYS_SELECT_H
42
#include <sys/select.h>
52
#define INADDR_NONE -1
57
#include <mystrings/utf8.h>
59
unsigned int drizzle_port=0;
63
unsigned int drizzleclient_get_default_port(void)
68
void drizzleclient_set_default_port(unsigned int port)
73
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
74
struct passwd *getpwuid(uid_t);
78
/*************************************************************************
79
put the row or field cursor one a position one got from DRIZZLE_ROW_tell()
80
This doesn't restore any data. The next drizzleclient_fetch_row or
81
drizzleclient_fetch_field will return the next row or field after the last used
82
*************************************************************************/
84
DRIZZLE_FIELD *drizzleclient_cli_list_fields(DRIZZLE *drizzle)
87
if (!(query= drizzleclient_cli_read_rows(drizzle,(DRIZZLE_FIELD*) 0, 8)))
90
drizzle->field_count= (uint32_t) query->rows;
91
return drizzleclient_unpack_fields(query, drizzle->field_count, 1);
94
const char *drizzleclient_cli_read_statistics(DRIZZLE *drizzle)
96
drizzle->net.read_pos[drizzle->packet_length]=0; /* End of stat string */
97
if (!drizzle->net.read_pos[0])
99
drizzleclient_set_error(drizzle, CR_WRONG_HOST_INFO, drizzleclient_sqlstate_get_unknown());
100
return drizzle->net.last_error;
102
return (char*) drizzle->net.read_pos;
105
/****************************************************************************
106
Some support functions
107
****************************************************************************/
109
int drizzleclient_cli_unbuffered_fetch(DRIZZLE *drizzle, char **row)
111
if (packet_error == drizzleclient_cli_safe_read(drizzle))
114
*row= ((drizzle->net.read_pos[0] == DRIZZLE_PROTOCOL_NO_MORE_DATA) ? NULL :
115
(char*) (drizzle->net.read_pos+1));