Bug 5055 - Simple SQL commands from the dialplan
[asterisk/asterisk.git] / funcs / func_odbc.c
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * func_odbc
5  * 
6  * Copyright (c) 2005 Tilghman Lesher
7  *
8  * Tilghman Lesher <func_odbc__200508@the-tilghman.com>
9  *
10  * Special thanks to Anthony Minessale II for debugging help.
11  */
12
13 #include <sys/types.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <string.h>
18 #include <asterisk/file.h>
19 #include <asterisk/logger.h>
20 #include <asterisk/options.h>
21 #include <asterisk/channel.h>
22 #include <asterisk/pbx.h>
23 #include <asterisk/module.h>
24 #include <asterisk/config.h>
25 #include <asterisk/res_odbc.h>
26
27 static char *tdesc = "ODBC lookups";
28
29 static char *config = "func_odbc.conf";
30
31 struct acf_odbc_query {
32         char name[30];
33         char dsn[30];
34         char sql_read[512];
35         char sql_write[512];
36         struct ast_custom_function *acf;
37         unsigned int deleteme:1;
38         struct acf_odbc_query *next;
39 };
40
41 static struct acf_odbc_query *queries = NULL;
42 AST_MUTEX_DEFINE_STATIC(query_lock);
43
44 #ifdef NEEDTRACE
45 static void acf_odbc_error(SQLHSTMT stmt, int res)
46 {
47         char state[10] = "", diagnostic[256] = "";
48         SQLINTEGER nativeerror = 0;
49         SQLSMALLINT diagbytes = 0;
50         SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeerror, diagnostic, sizeof(diagnostic), &diagbytes);
51         ast_log(LOG_WARNING, "SQL return value %d: error %s: %s (len %d)\n", res, state, diagnostic, diagbytes);
52 }
53 #endif
54
55 /*
56  * Master control routine
57  */
58 static void acf_odbc_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
59 {
60         odbc_obj *obj;
61         struct acf_odbc_query *query;
62         char *s, *t, *arg, buf[512]="", varname[15];
63         int res, argcount=0, valcount=0, i, retry=0;
64         struct ast_channel *ast;
65         SQLHSTMT stmt;
66         SQLINTEGER nativeerror=0, numfields=0, rows=0;
67         SQLSMALLINT diagbytes=0;
68         unsigned char state[10], diagnostic[256];
69 #ifdef NEEDTRACE
70         SQLINTEGER enable = 1;
71         char *tracefile = "/tmp/odbc.trace";
72 #endif
73
74         ast_mutex_lock(&query_lock);
75         for (query=queries; query; query = query->next) {
76                 if (!strcasecmp(query->name, cmd + 5)) {
77                         break;
78                 }
79         }
80
81         if (!query) {
82                 ast_log(LOG_ERROR, "No such function '%s'\n", cmd);
83                 ast_mutex_unlock(&query_lock);
84                 return;
85         }
86
87         obj = fetch_odbc_obj(query->dsn, 0);
88
89         if (!obj) {
90                 ast_log(LOG_ERROR, "No such DSN registered: %s (check res_odbc.conf)\n", query->dsn);
91                 ast_mutex_unlock(&query_lock);
92                 return;
93         }
94
95         /* Parse our arguments */
96         s = ast_strdupa(data);
97         if (value) {
98                 t = ast_strdupa(value);
99         } else {
100                 t = "";
101         }
102
103         if (!s || !t) {
104                 ast_log(LOG_ERROR, "Out of memory\n");
105                 ast_mutex_unlock(&query_lock);
106                 return;
107         }
108
109         /* XXX You might be tempted to change this section into using
110          * pbx_builtin_pushvar_helper().  However, note that if you try
111          * to set a NULL (like for VALUE), then nothing gets set, and the
112          * value doesn't get masked out.  Even worse, when you subsequently
113          * try to remove the value you just set, you'll wind up unsetting
114          * the previous value (which is wholly undesireable).  Hence, this
115          * has to remain the way it is done here. XXX
116          */
117
118         /* Save old arguments as variables in a fake channel */
119         ast = ast_channel_alloc(0);
120         while ((arg = strsep(&s, "|"))) {
121                 argcount++;
122                 snprintf(varname, sizeof(varname), "ARG%d", argcount);
123                 pbx_builtin_setvar_helper(ast, varname, pbx_builtin_getvar_helper(chan, varname));
124                 pbx_builtin_setvar_helper(chan, varname, arg);
125         }
126
127         /* Parse values, just like arguments */
128         while ((arg = strsep(&t, "|"))) {
129                 valcount++;
130                 snprintf(varname, sizeof(varname), "VAL%d", valcount);
131                 pbx_builtin_setvar_helper(ast, varname, pbx_builtin_getvar_helper(chan, varname));
132                 pbx_builtin_setvar_helper(chan, varname, arg);
133         }
134
135         /* Additionally set the value as a whole */
136         /* Note that pbx_builtin_setvar_helper will quite happily take a NULL for the 3rd argument */
137         pbx_builtin_setvar_helper(ast, "VALUE", pbx_builtin_getvar_helper(chan, "VALUE"));
138         pbx_builtin_setvar_helper(chan, "VALUE", value);
139
140         pbx_substitute_variables_helper(chan, query->sql_write, buf, sizeof(buf) - 1);
141
142         /* Restore prior values */
143         for (i=1; i<=argcount; i++) {
144                 snprintf(varname, sizeof(varname), "ARG%d", argcount);
145                 pbx_builtin_setvar_helper(chan, varname, pbx_builtin_getvar_helper(ast, varname));
146         }
147
148         for (i=1; i<=valcount; i++) {
149                 snprintf(varname, sizeof(varname), "VAL%d", argcount);
150                 pbx_builtin_setvar_helper(chan, varname, pbx_builtin_getvar_helper(ast, varname));
151         }
152         pbx_builtin_setvar_helper(chan, "VALUE", pbx_builtin_getvar_helper(ast, "VALUE"));
153
154         ast_channel_free(ast);
155         ast_mutex_unlock(&query_lock);
156
157 retry_write:
158 #ifdef NEEDTRACE
159         SQLSetConnectAttr(obj->con, SQL_ATTR_TRACE, &enable, SQL_IS_INTEGER);
160         SQLSetConnectAttr(obj->con, SQL_ATTR_TRACEFILE, tracefile, strlen(tracefile));
161 #endif
162
163         res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
164         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
165                 ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
166                 pbx_builtin_setvar_helper(chan, "ODBCROWS", "-1");
167                 return;
168         }
169
170         res = SQLPrepare(stmt, (unsigned char *)buf, SQL_NTS);
171         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
172                 ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", buf);
173                 SQLFreeHandle (SQL_HANDLE_STMT, stmt);
174                 pbx_builtin_setvar_helper(chan, "ODBCROWS", "-1");
175                 return;
176         }
177
178         res = SQLExecute(stmt);
179         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
180                 if (res == SQL_ERROR) {
181                         SQLGetDiagField(SQL_HANDLE_STMT, stmt, 1, SQL_DIAG_NUMBER, &numfields, SQL_IS_INTEGER, &diagbytes);
182                         for (i = 0; i <= numfields; i++) {
183                                 SQLGetDiagRec(SQL_HANDLE_STMT, stmt, i + 1, state, &nativeerror, diagnostic, sizeof(diagnostic), &diagbytes);
184                                 ast_log(LOG_WARNING, "SQL Execute returned an error %d: %s: %s (%d)\n", res, state, diagnostic, diagbytes);
185                                 if (i > 10) {
186                                         ast_log(LOG_WARNING, "Oh, that was good.  There are really %d diagnostics?\n", (int)numfields);
187                                         break;
188                                 }
189                         }
190                 }
191                 SQLFreeHandle(SQL_HANDLE_STMT, stmt);
192                 odbc_obj_disconnect(obj);
193                 /* All handles are now invalid (after a disconnect), so we gotta redo all handles */
194                 odbc_obj_connect(obj);
195                 if (!retry) {
196                         retry = 1;
197                         goto retry_write;
198                 }
199                 rows = -1;
200         } else {
201                 /* Rows affected */
202                 SQLRowCount(stmt, &rows);
203         }
204
205         /* Output the affected rows, for all cases.  In the event of failure, we
206          * flag this as -1 rows.  Note that this is different from 0 affected rows
207          * which would be the case if we succeeded in our query, but the values did
208          * not change. */
209         snprintf(varname, sizeof(varname), "%d", (int)rows);
210         pbx_builtin_setvar_helper(chan, "ODBCROWS", varname);
211
212         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
213                 ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", buf);
214         }
215
216         SQLFreeHandle(SQL_HANDLE_STMT, stmt);
217 }
218
219 static char *acf_odbc_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
220 {
221         odbc_obj *obj;
222         struct acf_odbc_query *query;
223         char *s, *arg, sql[512] = "", varname[15];
224         int count=0, res, x;
225         SQLHSTMT stmt;
226         SQLSMALLINT colcount=0;
227         SQLINTEGER indicator;
228 #ifdef NEEDTRACE
229         SQLINTEGER enable = 1;
230         char *tracefile = "/tmp/odbc.trace";
231 #endif
232
233         ast_mutex_lock(&query_lock);
234         for (query=queries; query; query = query->next) {
235                 if (!strcasecmp(query->name, cmd + 5)) {
236                         break;
237                 }
238         }
239
240         if (!query) {
241                 ast_log(LOG_ERROR, "No such function '%s'\n", cmd);
242                 ast_mutex_unlock(&query_lock);
243                 return "";
244         }
245
246         obj = fetch_odbc_obj(query->dsn, 0);
247
248         if (!obj) {
249                 ast_log(LOG_ERROR, "No such DSN registered: %s (check res_odbc.conf)\n", query->dsn);
250                 ast_mutex_unlock(&query_lock);
251                 return "";
252         }
253
254 #ifdef NEEDTRACE
255         SQLSetConnectAttr(obj->con, SQL_ATTR_TRACE, &enable, SQL_IS_INTEGER);
256         SQLSetConnectAttr(obj->con, SQL_ATTR_TRACEFILE, tracefile, strlen(tracefile));
257 #endif
258
259         /* Parse our arguments */
260         s = ast_strdupa(data);
261         if (!s) {
262                 ast_log(LOG_ERROR, "Out of memory\n");
263                 ast_mutex_unlock(&query_lock);
264                 return "";
265         }
266
267         while ((arg = strsep(&s, "|"))) {
268                 count++;
269                 snprintf(varname, sizeof(varname), "ARG%d", count);
270                 /* arg is by definition non-NULL, so this works, here */
271                 pbx_builtin_pushvar_helper(chan, varname, arg);
272         }
273
274         pbx_substitute_variables_helper(chan, query->sql_read, sql, sizeof(sql) - 1);
275
276         /* Restore prior values */
277         for (x = 1; x <= count; x++) {
278                 snprintf(varname, sizeof(varname), "ARG%d", x);
279                 pbx_builtin_setvar_helper(chan, varname, NULL);
280         }
281
282         ast_mutex_unlock(&query_lock);
283
284         res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
285         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
286                 ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
287                 return "";
288         }
289
290         res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
291         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
292                 ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
293                 SQLFreeHandle (SQL_HANDLE_STMT, stmt);
294                 return "";
295         }
296
297         res = odbc_smart_execute(obj, stmt);
298         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
299                 ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
300                 SQLFreeHandle (SQL_HANDLE_STMT, stmt);
301                 return "";
302         }
303
304         res = SQLNumResultCols(stmt, &colcount);
305         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
306                 ast_log(LOG_WARNING, "SQL Column Count error!\n[%s]\n\n", sql);
307                 SQLFreeHandle (SQL_HANDLE_STMT, stmt);
308                 return "";
309         }
310
311         memset(buf, 0, len);
312
313         res = SQLFetch(stmt);
314         if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
315                 if (res == SQL_NO_DATA) {
316                         if (option_verbose > 3) {
317                                 ast_verbose(VERBOSE_PREFIX_4 "Found no rows [%s]\n", sql);
318                         }
319                 } else if (option_verbose > 3) {
320                         ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql);
321                 }
322                 goto acf_out;
323         }
324
325         for (x=0; x<colcount; x++) {
326                 int buflen, coldatalen;
327                 char coldata[256];
328
329                 buflen = strlen(buf);
330                 res = SQLGetData(stmt, x + 1, SQL_CHAR, coldata, sizeof(coldata), &indicator);
331                 if (indicator == SQL_NULL_DATA) {
332                         coldata[0] = '\0';
333                         res = SQL_SUCCESS;
334                 }
335
336                 if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
337                         ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
338                         SQLFreeHandle(SQL_HANDLE_STMT, stmt);
339                         return "";
340                 }
341
342                 strncat(buf + buflen, coldata, len - buflen);
343                 coldatalen = strlen(coldata);
344                 strncat(buf + buflen + coldatalen, ",", len - buflen - coldatalen);
345         }
346         /* Trim trailing comma */
347         buf[strlen(buf) - 1] = '\0';
348
349 acf_out:
350         SQLFreeHandle(SQL_HANDLE_STMT, stmt);
351         return buf;
352 }
353
354 static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_query **query)
355 {
356         char *tmp;
357
358         if (!cfg || !catg) {
359                 return -1;
360         }
361
362         *query = calloc(1, sizeof(struct acf_odbc_query));
363         if (! (*query))
364                 return -1;
365
366         ast_copy_string((*query)->name, catg, sizeof((*query)->name));
367
368         if ((tmp = ast_variable_retrieve(cfg, catg, "dsn"))) {
369                 ast_copy_string((*query)->dsn, tmp, sizeof((*query)->dsn));
370         } else {
371                 return -1;
372         }
373
374         if ((tmp = ast_variable_retrieve(cfg, catg, "read"))) {
375                 ast_copy_string((*query)->sql_read, tmp, sizeof((*query)->sql_read));
376         }
377
378         if ((tmp = ast_variable_retrieve(cfg, catg, "write"))) {
379                 ast_copy_string((*query)->sql_write, tmp, sizeof((*query)->sql_write));
380         }
381
382         (*query)->acf = calloc(1, sizeof(struct ast_custom_function));
383         if ((*query)->acf) {
384                 asprintf(&((*query)->acf->name), "ODBC_%s", catg);
385                 asprintf(&((*query)->acf->syntax), "ODBC_%s(<arg1>[...[,<argN>]])", catg);
386                 (*query)->acf->synopsis = "Runs the referenced query with the specified arguments";
387                 if (!ast_strlen_zero((*query)->sql_read) && !ast_strlen_zero((*query)->sql_write)) {
388                         asprintf(&((*query)->acf->desc),
389                                                 "Runs the following query, as defined in func_odbc.conf, performing\n"
390                                                 "substitution of the arguments into the query as specified by ${ARG1},\n"
391                                                 "${ARG2}, ... ${ARGn}.  When setting the function, the values are provided\n"
392                                                 "either in whole as ${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n"
393                                                 "\nRead:\n%s\n\nWrite:\n%s\n",
394                                                 (*query)->sql_read,
395                                                 (*query)->sql_write);
396                 } else if (!ast_strlen_zero((*query)->sql_read)) {
397                         asprintf(&((*query)->acf->desc),
398                                                 "Runs the following query, as defined in func_odbc.conf, performing\n"
399                                                 "substitution of the arguments into the query as specified by ${ARG1},\n"
400                                                 "${ARG2}, ... ${ARGn}.  This function may only be read, not set.\n\nSQL:\n%s\n",
401                                                 (*query)->sql_read);
402                 } else if (!ast_strlen_zero((*query)->sql_write)) {
403                         asprintf(&((*query)->acf->desc),
404                                                 "Runs the following query, as defined in func_odbc.conf, performing\n"
405                                                 "substitution of the arguments into the query as specified by ${ARG1},\n"
406                                                 "${ARG2}, ... ${ARGn}.  The values are provided either in whole as\n"
407                                                 "${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n"
408                                                 "This function may only be set.\nSQL:\n%s\n",
409                                                 (*query)->sql_write);
410                 }
411
412                 if (ast_strlen_zero((*query)->sql_read)) {
413                         (*query)->acf->read = NULL;
414                 } else {
415                         (*query)->acf->read = acf_odbc_read;
416                 }
417
418                 if (ast_strlen_zero((*query)->sql_write)) {
419                         (*query)->acf->write = NULL;
420                 } else {
421                         (*query)->acf->write = acf_odbc_write;
422                 }
423
424                 if (! (*query)->acf->name || ! (*query)->acf->syntax || ! (*query)->acf->desc) {
425                         return -1;
426                 }
427         } else {
428                 return -1;
429         }
430         return 0;
431 }
432
433 static int free_acf_query(struct acf_odbc_query *query)
434 {
435         if (query) {
436                 if (query->acf) {
437                         if (query->acf->name)
438                                 free(query->acf->name);
439                         if (query->acf->syntax)
440                                 free(query->acf->syntax);
441                         if (query->acf->desc)
442                                 free(query->acf->desc);
443                         free(query->acf);
444                 }
445                 free(query);
446         }
447         return 0;
448 }
449
450 static int odbc_load_module(void)
451 {
452         int res = 0;
453         struct ast_config *cfg;
454         char *catg;
455
456         ast_mutex_lock(&query_lock);
457
458         cfg = ast_config_load(config);
459         if (!cfg) {
460                 ast_log(LOG_WARNING, "Unable to load config for func_odbc: %s\n", config);
461                 goto out;
462         }
463
464         for (catg = ast_category_browse(cfg, NULL);
465                  catg;
466                  catg = ast_category_browse(cfg, catg)) {
467                 struct acf_odbc_query *query=NULL;
468
469                 if (init_acf_query(cfg, catg, &query)) {
470                         ast_log(LOG_ERROR, "Out of memory\n");
471                         free_acf_query(query);
472                 } else {
473                         query->next = queries;
474                         queries = query;
475                         ast_custom_function_register(query->acf);
476                 }
477         }
478
479         ast_config_destroy(cfg);
480 out:
481         ast_mutex_unlock(&query_lock);
482         return res;
483 }
484
485 static int odbc_unload_module(void)
486 {
487         struct acf_odbc_query *query, *lastquery = NULL;
488
489         ast_mutex_lock(&query_lock);
490         for (query = queries; query; query = query->next) {
491                 if (lastquery)
492                         free_acf_query(lastquery);
493                 if (ast_custom_function_unregister(query->acf)) {
494                         ast_log(LOG_ERROR, "Cannot unregister function '%s'?\n", query->acf->name);
495                         /* Keep state valid */
496                         queries = query;
497                         ast_mutex_unlock(&query_lock);
498                         return -1;
499                 } else {
500                         /* If anything is waiting on this lock, this will let it pass (avoids a race) */
501                         ast_mutex_unlock(&query_lock);
502                         ast_mutex_lock(&query_lock);
503                         lastquery = query;
504                 }
505         }
506         if (lastquery)
507                 free(lastquery);
508         queries = NULL;
509
510         ast_mutex_unlock(&query_lock);
511         return 0;
512 }
513
514 int reload(void)
515 {
516         int res = 0;
517         struct ast_config *cfg;
518         struct acf_odbc_query *q, *prevq = NULL, *qdel = NULL;
519         char *catg;
520
521         ast_mutex_lock(&query_lock);
522
523         for (q = queries; q; q = q->next) {
524                 q->deleteme = 1;
525         }
526
527         cfg = ast_config_load(config);
528         if (!cfg) {
529                 ast_log(LOG_WARNING, "Unable to load config for func_odbc: %s\n", config);
530                 goto reload_out;
531         }
532
533         for (catg = ast_category_browse(cfg, NULL);
534                  catg;
535                  catg = ast_category_browse(cfg, catg)) {
536                 struct acf_odbc_query *query = NULL;
537
538                 /* We do this piecemeal, so that we stay in a consistent state, if there's ever an error */
539                 for (q = queries, prevq=NULL; q; prevq=q, q = q->next) {
540                         if (!strcasecmp(catg, q->name)) {
541                                 break;
542                         }
543                 }
544
545                 if (init_acf_query(cfg, catg, &query)) {
546                         ast_log(LOG_ERROR, "Cannot initialize query ODBC_%s\n", catg);
547                         free_acf_query(query);
548                 } else {
549                         if (q) {
550                                 /* Replacement */
551                                 if (ast_custom_function_unregister(q->acf)) {
552                                         ast_log(LOG_ERROR, "Cannot reload query %s\n", query->acf->name);
553                                         free_acf_query(query);
554                                 } else {
555                                         ast_custom_function_register(query->acf);
556                                         /* Add it to the list */
557                                         if (prevq)
558                                                 prevq->next = query;
559                                         else
560                                                 queries = query;
561                                         query->next = q->next;
562                                         /* Get rid of the old record */
563                                         free_acf_query(q);
564                                 }
565                         } else {
566                                 /* New */
567                                 query->next = queries;
568                                 queries = query;
569                                 ast_custom_function_register(query->acf);
570                         }
571                 }
572         }
573
574         /* Any remaining sets will now be destroyed */
575         for (q = queries; q; q = q->next) {
576                 if (qdel) {
577                         free_acf_query(qdel);
578                         qdel = NULL;
579                 }
580
581                 if (q->deleteme) {
582                         if (ast_custom_function_unregister(q->acf)) {
583                                 ast_log(LOG_ERROR, "Cannot unregister function?  Refusing to make 'ODBC_%s' go away.\n", q->name);
584                         } else {
585                                 /* If anything is waiting on the lock to execute, this will dispose of it (without a race) */
586                                 ast_mutex_unlock(&query_lock);
587                                 ast_mutex_lock(&query_lock);
588
589                                 if (prevq) {
590                                         prevq->next = q->next;
591                                 } else {
592                                         queries = q->next;
593                                 }
594                                 qdel = q;
595                         }
596                 } else {
597                         prevq = q;
598                 }
599         }
600         if (qdel)
601                 free_acf_query(qdel);
602
603         ast_config_destroy(cfg);
604 reload_out:
605         ast_mutex_unlock(&query_lock);
606         return res;
607 }
608
609 int unload_module(void)
610 {
611         return odbc_unload_module();
612 }
613
614 int load_module(void)
615 {
616         return odbc_load_module();
617 }
618
619 char *description(void)
620 {
621         return tdesc;
622 }
623
624 int usecount(void)
625 {
626         if (! ast_mutex_trylock(&query_lock)) {
627                 ast_mutex_unlock(&query_lock);
628                 return 0;
629         } else {
630                 return 1;
631         }
632 }
633
634 char *key()
635 {
636         return ASTERISK_GPL_KEY;
637 }