~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to examples/server.c

  • Committer: Brian Aker
  • Date: 2010-09-12 01:42:27 UTC
  • mto: (1759.2.1 build)
  • mto: This revision was merged to the branch mainline in revision 1762.
  • Revision ID: brian@tangent.org-20100912014227-krt6d9z5ohqrokhb
Add two plugins to handle the string and math functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
5
 * All rights reserved.
6
6
 *
7
 
 * Redistribution and use in source and binary forms, with or without
8
 
 * modification, are permitted provided that the following conditions are
9
 
 * met:
10
 
 *
11
 
 *     * Redistributions of source code must retain the above copyright
12
 
 * notice, this list of conditions and the following disclaimer.
13
 
 *
14
 
 *     * Redistributions in binary form must reproduce the above
15
 
 * copyright notice, this list of conditions and the following disclaimer
16
 
 * in the documentation and/or other materials provided with the
17
 
 * distribution.
18
 
 *
19
 
 *     * The names of its contributors may not be used to endorse or
20
 
 * promote products derived from this software without specific prior
21
 
 * written permission.
22
 
 *
23
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 
 *
 
7
 * Use and distribution licensed under the BSD license.  See
 
8
 * the COPYING file in this directory for full text.
35
9
 */
36
10
 
37
 
 
38
11
#include <errno.h>
39
12
#include <stdio.h>
40
13
#include <stdlib.h>
70
43
  drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
71
44
  drizzle_return_t ret;
72
45
  drizzle_st drizzle;
73
 
  drizzle_con_st *con_listen= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
74
 
  drizzle_con_st *con= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
 
46
  drizzle_con_st con_listen;
 
47
  drizzle_con_st con;
75
48
  drizzle_result_st result;
76
49
  drizzle_column_st column;
77
50
 
120
93
  drizzle_add_options(&drizzle, DRIZZLE_FREE_OBJECTS);
121
94
  drizzle_set_verbose(&drizzle, verbose);
122
95
 
123
 
  if (drizzle_con_create(&drizzle, con_listen) == NULL)
 
96
  if (drizzle_con_create(&drizzle, &con_listen) == NULL)
124
97
  {
125
98
    printf("drizzle_con_create:NULL\n");
126
99
    return 1;
127
100
  }
128
101
 
129
 
  drizzle_con_add_options(con_listen, DRIZZLE_CON_LISTEN);
130
 
  drizzle_con_set_tcp(con_listen, host, port);
 
102
  drizzle_con_add_options(&con_listen, DRIZZLE_CON_LISTEN);
 
103
  drizzle_con_set_tcp(&con_listen, host, port);
131
104
 
132
105
  if (mysql)
133
 
    drizzle_con_add_options(con_listen, DRIZZLE_CON_MYSQL);
 
106
    drizzle_con_add_options(&con_listen, DRIZZLE_CON_MYSQL);
134
107
 
135
 
  if (drizzle_con_listen(con_listen) != DRIZZLE_RETURN_OK)
 
108
  if (drizzle_con_listen(&con_listen) != DRIZZLE_RETURN_OK)
136
109
  {
137
110
    printf("drizzle_con_listen:%s\n", drizzle_error(&drizzle));
138
111
    return 1;
140
113
 
141
114
  while (1)
142
115
  {
143
 
    (void)drizzle_con_accept(&drizzle, con, &ret);
 
116
    (void)drizzle_con_accept(&drizzle, &con, &ret);
144
117
    if (ret != DRIZZLE_RETURN_OK)
145
118
    {
146
119
      printf("drizzle_con_accept:%s\n", drizzle_error(&drizzle));
147
120
      return 1;
148
121
    }
149
122
 
150
 
    server(&drizzle, con, &result, &column);
 
123
    server(&drizzle, &con, &result, &column);
151
124
 
152
 
    drizzle_con_free(con);
 
125
    drizzle_con_free(&con);
153
126
 
154
127
    if (count > 0)
155
128
    {
160
133
    }
161
134
  }
162
135
 
163
 
  drizzle_con_free(con_listen);
 
136
  drizzle_con_free(&con_listen);
164
137
  drizzle_free(&drizzle);
165
138
 
166
 
  free(con);
167
 
  free(con_listen);
168
 
 
169
139
  return 0;
170
140
}
171
141