~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/oldlibdrizzle/libdrizzle.cc

  • Committer: Stewart Smith
  • Date: 2009-10-08 12:39:27 UTC
  • mto: This revision was merged to the branch mainline in revision 1179.
  • Revision ID: stewart@flamingspork.com-20091008123927-qpf9hog04w4xc5aj
make directory_file_name() static to mysys/my_lib.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
 
19
 
 
20
#include <drizzled/global.h>
 
21
#include "libdrizzle_priv.h"
 
22
 
 
23
#include "libdrizzle.h"
 
24
#include "errmsg.h"
 
25
#include "pack.h"
 
26
 
 
27
#include <sys/stat.h>
 
28
#include <signal.h>
 
29
#include <time.h>
 
30
#ifdef   HAVE_PWD_H
 
31
#include <pwd.h>
 
32
#endif
 
33
 
 
34
#include <sys/socket.h>
 
35
#include <netinet/in.h>
 
36
#include <arpa/inet.h>
 
37
#include <netdb.h>
 
38
#ifdef HAVE_SELECT_H
 
39
#include <select.h>
 
40
#endif
 
41
#ifdef HAVE_SYS_SELECT_H
 
42
#include <sys/select.h>
 
43
#endif
 
44
 
 
45
#ifdef HAVE_POLL
 
46
#include <sys/poll.h>
 
47
#endif
 
48
#ifdef HAVE_SYS_UN_H
 
49
#include <sys/un.h>
 
50
#endif
 
51
#ifndef INADDR_NONE
 
52
#define INADDR_NONE  -1
 
53
#endif
 
54
 
 
55
#include <stdlib.h>
 
56
#include <string.h>
 
57
#include <mystrings/utf8.h>
 
58
 
 
59
unsigned int drizzle_port=0;
 
60
 
 
61
#include <errno.h>
 
62
 
 
63
unsigned int drizzleclient_get_default_port(void)
 
64
{
 
65
  return drizzle_port;
 
66
}
 
67
 
 
68
void drizzleclient_set_default_port(unsigned int port)
 
69
{
 
70
  drizzle_port= port;
 
71
}
 
72
 
 
73
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
 
74
struct passwd *getpwuid(uid_t);
 
75
char* getlogin(void);
 
76
#endif
 
77
 
 
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
*************************************************************************/
 
83
 
 
84
DRIZZLE_FIELD *drizzleclient_cli_list_fields(DRIZZLE *drizzle)
 
85
{
 
86
  DRIZZLE_DATA *query;
 
87
  if (!(query= drizzleclient_cli_read_rows(drizzle,(DRIZZLE_FIELD*) 0, 8)))
 
88
    return NULL;
 
89
 
 
90
  drizzle->field_count= (uint32_t) query->rows;
 
91
  return drizzleclient_unpack_fields(query, drizzle->field_count, 1);
 
92
}
 
93
 
 
94
const char *drizzleclient_cli_read_statistics(DRIZZLE *drizzle)
 
95
{
 
96
  drizzle->net.read_pos[drizzle->packet_length]=0;  /* End of stat string */
 
97
  if (!drizzle->net.read_pos[0])
 
98
  {
 
99
    drizzleclient_set_error(drizzle, CR_WRONG_HOST_INFO, drizzleclient_sqlstate_get_unknown());
 
100
    return drizzle->net.last_error;
 
101
  }
 
102
  return (char*) drizzle->net.read_pos;
 
103
}
 
104
 
 
105
/****************************************************************************
 
106
  Some support functions
 
107
****************************************************************************/
 
108
 
 
109
int drizzleclient_cli_unbuffered_fetch(DRIZZLE *drizzle, char **row)
 
110
{
 
111
  if (packet_error == drizzleclient_cli_safe_read(drizzle))
 
112
    return 1;
 
113
 
 
114
  *row= ((drizzle->net.read_pos[0] == DRIZZLE_PROTOCOL_NO_MORE_DATA) ? NULL :
 
115
   (char*) (drizzle->net.read_pos+1));
 
116
  return 0;
 
117
}
 
118