Implement initial Python bindings for Open vSwitch database.
[sliver-openvswitch.git] / ovsdb / ovsdb-idlc.in
1 #! @PYTHON@
2
3 import getopt
4 import os
5 import re
6 import sys
7
8 import ovs.json
9 import ovs.db.error
10 import ovs.db.schema
11
12 argv0 = sys.argv[0]
13
14 def parseSchema(filename):
15     return ovs.db.schema.IdlSchema.from_json(ovs.json.from_file(filename))
16
17 def annotateSchema(schemaFile, annotationFile):
18     schemaJson = ovs.json.from_file(schemaFile)
19     execfile(annotationFile, globals(), {"s": schemaJson})
20     ovs.json.to_stream(schemaJson, sys.stdout)
21
22 def constify(cType, const):
23     if (const
24         and cType.endswith('*') and not cType.endswith('**')
25         and (cType.startswith('struct uuid') or cType.startswith('char'))):
26         return 'const %s' % cType
27     else:
28         return cType
29
30 def cMembers(prefix, columnName, column, const):
31     type = column.type
32     if type.n_min == 1 and type.n_max == 1:
33         singleton = True
34         pointer = ''
35     else:
36         singleton = False
37         if type.is_optional_pointer():
38             pointer = ''
39         else:
40             pointer = '*'
41
42     if type.value:
43         key = {'name': "key_%s" % columnName,
44                'type': constify(type.key.toCType(prefix) + pointer, const),
45                'comment': ''}
46         value = {'name': "value_%s" % columnName,
47                  'type': constify(type.value.toCType(prefix) + pointer, const),
48                  'comment': ''}
49         members = [key, value]
50     else:
51         m = {'name': columnName,
52              'type': constify(type.key.toCType(prefix) + pointer, const),
53              'comment': type.cDeclComment()}
54         members = [m]
55
56     if not singleton and not type.is_optional_pointer():
57         members.append({'name': 'n_%s' % columnName,
58                         'type': 'size_t ',
59                         'comment': ''})
60     return members
61
62 def printCIDLHeader(schemaFile):
63     schema = parseSchema(schemaFile)
64     prefix = schema.idlPrefix
65     print '''\
66 /* Generated automatically -- do not modify!    -*- buffer-read-only: t -*- */
67
68 #ifndef %(prefix)sIDL_HEADER
69 #define %(prefix)sIDL_HEADER 1
70
71 #include <stdbool.h>
72 #include <stddef.h>
73 #include <stdint.h>
74 #include "ovsdb-data.h"
75 #include "ovsdb-idl-provider.h"
76 #include "uuid.h"''' % {'prefix': prefix.upper()}
77
78     for tableName, table in sorted(schema.tables.iteritems()):
79         structName = "%s%s" % (prefix, tableName.lower())
80
81         print "\f"
82         print "/* %s table. */" % tableName
83         print "struct %s {" % structName
84         print "\tstruct ovsdb_idl_row header_;"
85         for columnName, column in sorted(table.columns.iteritems()):
86             print "\n\t/* %s column. */" % columnName
87             for member in cMembers(prefix, columnName, column, False):
88                 print "\t%(type)s%(name)s;%(comment)s" % member
89         print "};"
90
91         # Column indexes.
92         printEnum(["%s_COL_%s" % (structName.upper(), columnName.upper())
93                    for columnName in sorted(table.columns)]
94                   + ["%s_N_COLUMNS" % structName.upper()])
95
96         print
97         for columnName in table.columns:
98             print "#define %(s)s_col_%(c)s (%(s)s_columns[%(S)s_COL_%(C)s])" % {
99                 's': structName,
100                 'S': structName.upper(),
101                 'c': columnName,
102                 'C': columnName.upper()}
103
104         print "\nextern struct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % (structName, structName.upper())
105
106         print '''
107 const struct %(s)s *%(s)s_first(const struct ovsdb_idl *);
108 const struct %(s)s *%(s)s_next(const struct %(s)s *);
109 #define %(S)s_FOR_EACH(ROW, IDL) \\
110         for ((ROW) = %(s)s_first(IDL); \\
111              (ROW); \\
112              (ROW) = %(s)s_next(ROW))
113 #define %(S)s_FOR_EACH_SAFE(ROW, NEXT, IDL) \\
114         for ((ROW) = %(s)s_first(IDL); \\
115              (ROW) ? ((NEXT) = %(s)s_next(ROW), 1) : 0; \\
116              (ROW) = (NEXT))
117
118 void %(s)s_delete(const struct %(s)s *);
119 struct %(s)s *%(s)s_insert(struct ovsdb_idl_txn *);
120 ''' % {'s': structName, 'S': structName.upper()}
121
122         for columnName, column in sorted(table.columns.iteritems()):
123             print 'void %(s)s_verify_%(c)s(const struct %(s)s *);' % {'s': structName, 'c': columnName}
124
125         print """
126 /* Functions for fetching columns as \"struct ovsdb_datum\"s.  (This is
127    rarely useful.  More often, it is easier to access columns by using
128    the members of %(s)s directly.) */""" % {'s': structName}
129         for columnName, column in sorted(table.columns.iteritems()):
130             if column.type.value:
131                 valueParam = ', enum ovsdb_atomic_type value_type'
132             else:
133                 valueParam = ''
134             print 'const struct ovsdb_datum *%(s)s_get_%(c)s(const struct %(s)s *, enum ovsdb_atomic_type key_type%(v)s);' % {
135                 's': structName, 'c': columnName, 'v': valueParam}
136
137         print
138         for columnName, column in sorted(table.columns.iteritems()):
139
140             print 'void %(s)s_set_%(c)s(const struct %(s)s *,' % {'s': structName, 'c': columnName},
141             args = ['%(type)s%(name)s' % member for member
142                     in cMembers(prefix, columnName, column, True)]
143             print '%s);' % ', '.join(args)
144
145     # Table indexes.
146     printEnum(["%sTABLE_%s" % (prefix.upper(), tableName.upper()) for tableName in sorted(schema.tables)] + ["%sN_TABLES" % prefix.upper()])
147     print
148     for tableName in schema.tables:
149         print "#define %(p)stable_%(t)s (%(p)stable_classes[%(P)sTABLE_%(T)s])" % {
150             'p': prefix,
151             'P': prefix.upper(),
152             't': tableName.lower(),
153             'T': tableName.upper()}
154     print "\nextern struct ovsdb_idl_table_class %stable_classes[%sN_TABLES];" % (prefix, prefix.upper())
155
156     print "\nextern struct ovsdb_idl_class %sidl_class;" % prefix
157     print "\nvoid %sinit(void);" % prefix
158     print "\n#endif /* %(prefix)sIDL_HEADER */" % {'prefix': prefix.upper()}
159
160 def printEnum(members):
161     if len(members) == 0:
162         return
163
164     print "\nenum {";
165     for member in members[:-1]:
166         print "    %s," % member
167     print "    %s" % members[-1]
168     print "};"
169
170 def printCIDLSource(schemaFile):
171     schema = parseSchema(schemaFile)
172     prefix = schema.idlPrefix
173     print '''\
174 /* Generated automatically -- do not modify!    -*- buffer-read-only: t -*- */
175
176 #include <config.h>
177 #include %s
178 #include <assert.h>
179 #include <limits.h>
180 #include "ovsdb-data.h"
181 #include "ovsdb-error.h"
182
183 static bool inited;
184 ''' % schema.idlHeader
185
186     # Cast functions.
187     for tableName, table in sorted(schema.tables.iteritems()):
188         structName = "%s%s" % (prefix, tableName.lower())
189         print '''
190 static struct %(s)s *
191 %(s)s_cast(const struct ovsdb_idl_row *row)
192 {
193     return row ? CONTAINER_OF(row, struct %(s)s, header_) : NULL;
194 }\
195 ''' % {'s': structName}
196
197
198     for tableName, table in sorted(schema.tables.iteritems()):
199         structName = "%s%s" % (prefix, tableName.lower())
200         print "\f"
201         print "/* %s table. */" % (tableName)
202
203         # Parse functions.
204         for columnName, column in sorted(table.columns.iteritems()):
205             print '''
206 static void
207 %(s)s_parse_%(c)s(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
208 {
209     struct %(s)s *row = %(s)s_cast(row_);''' % {'s': structName,
210                                                 'c': columnName}
211
212             type = column.type
213             if type.value:
214                 keyVar = "row->key_%s" % columnName
215                 valueVar = "row->value_%s" % columnName
216             else:
217                 keyVar = "row->%s" % columnName
218                 valueVar = None
219
220             if (type.n_min == 1 and type.n_max == 1) or type.is_optional_pointer():
221                 print
222                 print "    assert(inited);"
223                 print "    if (datum->n >= 1) {"
224                 if not type.key.ref_table:
225                     print "        %s = datum->keys[0].%s;" % (keyVar, type.key.type.to_string())
226                 else:
227                     print "        %s = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_classes[%sTABLE_%s], &datum->keys[0].uuid));" % (keyVar, prefix, type.key.ref_table.lower(), prefix, prefix.upper(), type.key.ref_table.upper())
228
229                 if valueVar:
230                     if type.value.ref_table:
231                         print "        %s = datum->values[0].%s;" % (valueVar, type.value.type.to_string())
232                     else:
233                         print "        %s = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_classes[%sTABLE_%s], &datum->values[0].uuid));" % (valueVar, prefix, type.value.ref_table.lower(), prefix, prefix.upper(), type.value.ref_table.upper())
234                 print "    } else {"
235                 print "        %s" % type.key.initCDefault(keyVar, type.n_min == 0)
236                 if valueVar:
237                     print "        %s" % type.value.initCDefault(valueVar, type.n_min == 0)
238                 print "    }"
239             else:
240                 if type.n_max != sys.maxint:
241                     print "    size_t n = MIN(%d, datum->n);" % type.n_max
242                     nMax = "n"
243                 else:
244                     nMax = "datum->n"
245                 print "    size_t i;"
246                 print
247                 print "    assert(inited);"
248                 print "    %s = NULL;" % keyVar
249                 if valueVar:
250                     print "    %s = NULL;" % valueVar
251                 print "    row->n_%s = 0;" % columnName
252                 print "    for (i = 0; i < %s; i++) {" % nMax
253                 refs = []
254                 if type.key.ref_table:
255                     print "        struct %s%s *keyRow = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_classes[%sTABLE_%s], &datum->keys[i].uuid));" % (prefix, type.key.ref_table.lower(), prefix, type.key.ref_table.lower(), prefix, prefix.upper(), type.key.ref_table.upper())
256                     keySrc = "keyRow"
257                     refs.append('keyRow')
258                 else:
259                     keySrc = "datum->keys[i].%s" % type.key.type.to_string()
260                 if type.value and type.value.ref_table:
261                     print "        struct %s%s *valueRow = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_classes[%sTABLE_%s], &datum->values[i].uuid));" % (prefix, type.value.ref_table.lower(), prefix, type.value.ref_table.lower(), prefix, prefix.upper(), type.value.ref_table.upper())
262                     valueSrc = "valueRow"
263                     refs.append('valueRow')
264                 elif valueVar:
265                     valueSrc = "datum->values[i].%s" % type.value.type.to_string()
266                 if refs:
267                     print "        if (%s) {" % ' && '.join(refs)
268                     indent = "            "
269                 else:
270                     indent = "        "
271                 print "%sif (!row->n_%s) {" % (indent, columnName)
272                 print "%s    %s = xmalloc(%s * sizeof *%s);" % (indent, keyVar, nMax, keyVar)
273                 if valueVar:
274                     print "%s    %s = xmalloc(%s * sizeof *%s);" % (indent, valueVar, nMax, valueVar)
275                 print "%s}" % indent
276                 print "%s%s[row->n_%s] = %s;" % (indent, keyVar, columnName, keySrc)
277                 if valueVar:
278                     print "%s%s[row->n_%s] = %s;" % (indent, valueVar, columnName, valueSrc)
279                 print "%srow->n_%s++;" % (indent, columnName)
280                 if refs:
281                     print "        }"
282                 print "    }"
283             print "}"
284
285         # Unparse functions.
286         for columnName, column in sorted(table.columns.iteritems()):
287             type = column.type
288             if (type.n_min != 1 or type.n_max != 1) and not type.is_optional_pointer():
289                 print '''
290 static void
291 %(s)s_unparse_%(c)s(struct ovsdb_idl_row *row_)
292 {
293     struct %(s)s *row = %(s)s_cast(row_);
294
295     assert(inited);''' % {'s': structName, 'c': columnName}
296                 if type.value:
297                     keyVar = "row->key_%s" % columnName
298                     valueVar = "row->value_%s" % columnName
299                 else:
300                     keyVar = "row->%s" % columnName
301                     valueVar = None
302                 print "    free(%s);" % keyVar
303                 if valueVar:
304                     print "    free(%s);" % valueVar
305                 print '}'
306             else:
307                 print '''
308 static void
309 %(s)s_unparse_%(c)s(struct ovsdb_idl_row *row OVS_UNUSED)
310 {
311     /* Nothing to do. */
312 }''' % {'s': structName, 'c': columnName}
313  
314         # First, next functions.
315         print '''
316 const struct %(s)s *
317 %(s)s_first(const struct ovsdb_idl *idl)
318 {
319     return %(s)s_cast(ovsdb_idl_first_row(idl, &%(p)stable_classes[%(P)sTABLE_%(T)s]));
320 }
321
322 const struct %(s)s *
323 %(s)s_next(const struct %(s)s *row)
324 {
325     return %(s)s_cast(ovsdb_idl_next_row(&row->header_));
326 }''' % {'s': structName,
327         'p': prefix,
328         'P': prefix.upper(),
329         'T': tableName.upper()}
330
331         print '''
332 void
333 %(s)s_delete(const struct %(s)s *row)
334 {
335     ovsdb_idl_txn_delete(&row->header_);
336 }
337
338 struct %(s)s *
339 %(s)s_insert(struct ovsdb_idl_txn *txn)
340 {
341     return %(s)s_cast(ovsdb_idl_txn_insert(txn, &%(p)stable_classes[%(P)sTABLE_%(T)s], NULL));
342 }
343 ''' % {'s': structName,
344        'p': prefix,
345        'P': prefix.upper(),
346        'T': tableName.upper()}
347
348         # Verify functions.
349         for columnName, column in sorted(table.columns.iteritems()):
350             print '''
351 void
352 %(s)s_verify_%(c)s(const struct %(s)s *row)
353 {
354     assert(inited);
355     ovsdb_idl_txn_verify(&row->header_, &%(s)s_columns[%(S)s_COL_%(C)s]);
356 }''' % {'s': structName,
357         'S': structName.upper(),
358         'c': columnName,
359         'C': columnName.upper()}
360
361         # Get functions.
362         for columnName, column in sorted(table.columns.iteritems()):
363             if column.type.value:
364                 valueParam = ',\n\tenum ovsdb_atomic_type value_type OVS_UNUSED'
365                 valueType = '\n    assert(value_type == %s);' % column.type.value.toAtomicType()
366                 valueComment = "\n * 'value_type' must be %s." % column.type.value.toAtomicType()
367             else:
368                 valueParam = ''
369                 valueType = ''
370                 valueComment = ''
371             print """
372 /* Returns the %(c)s column's value in 'row' as a struct ovsdb_datum.
373  * This is useful occasionally: for example, ovsdb_datum_find_key() is an
374  * easier and more efficient way to search for a given key than implementing
375  * the same operation on the "cooked" form in 'row'.
376  *
377  * 'key_type' must be %(kt)s.%(vc)s
378  * (This helps to avoid silent bugs if someone changes %(c)s's
379  * type without updating the caller.)
380  *
381  * The caller must not modify or free the returned value.
382  *
383  * Various kinds of changes can invalidate the returned value: modifying
384  * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
385  * If the returned value is needed for a long time, it is best to make a copy
386  * of it with ovsdb_datum_clone(). */
387 const struct ovsdb_datum *
388 %(s)s_get_%(c)s(const struct %(s)s *row,
389 \tenum ovsdb_atomic_type key_type OVS_UNUSED%(v)s)
390 {
391     assert(key_type == %(kt)s);%(vt)s
392     return ovsdb_idl_read(&row->header_, &%(s)s_col_%(c)s);
393 }""" % {'s': structName, 'c': columnName,
394        'kt': column.type.key.toAtomicType(),
395        'v': valueParam, 'vt': valueType, 'vc': valueComment}
396
397         # Set functions.
398         for columnName, column in sorted(table.columns.iteritems()):
399             type = column.type
400             print '\nvoid'
401             members = cMembers(prefix, columnName, column, True)
402             keyVar = members[0]['name']
403             nVar = None
404             valueVar = None
405             if type.value:
406                 valueVar = members[1]['name']
407                 if len(members) > 2:
408                     nVar = members[2]['name']
409             else:
410                 if len(members) > 1:
411                     nVar = members[1]['name']
412             print '%(s)s_set_%(c)s(const struct %(s)s *row, %(args)s)' % \
413                 {'s': structName, 'c': columnName,
414                  'args': ', '.join(['%(type)s%(name)s' % m for m in members])}
415             print "{"
416             print "    struct ovsdb_datum datum;"
417             if type.n_min == 1 and type.n_max == 1:
418                 print
419                 print "    assert(inited);"
420                 print "    datum.n = 1;"
421                 print "    datum.keys = xmalloc(sizeof *datum.keys);"
422                 print "    " + type.key.copyCValue("datum.keys[0].%s" % type.key.type.to_string(), keyVar)
423                 if type.value:
424                     print "    datum.values = xmalloc(sizeof *datum.values);"
425                     print "    "+ type.value.copyCValue("datum.values[0].%s" % type.value.type.to_string(), valueVar)
426                 else:
427                     print "    datum.values = NULL;"
428             elif type.is_optional_pointer():
429                 print
430                 print "    assert(inited);"
431                 print "    if (%s) {" % keyVar
432                 print "        datum.n = 1;"
433                 print "        datum.keys = xmalloc(sizeof *datum.keys);"
434                 print "        " + type.key.copyCValue("datum.keys[0].%s" % type.key.type.to_string(), keyVar)
435                 print "    } else {"
436                 print "        datum.n = 0;"
437                 print "        datum.keys = NULL;"
438                 print "    }"
439                 print "    datum.values = NULL;"
440             else:
441                 print "    size_t i;"
442                 print
443                 print "    assert(inited);"
444                 print "    datum.n = %s;" % nVar
445                 print "    datum.keys = xmalloc(%s * sizeof *datum.keys);" % nVar
446                 if type.value:
447                     print "    datum.values = xmalloc(%s * sizeof *datum.values);" % nVar
448                 else:
449                     print "    datum.values = NULL;"
450                 print "    for (i = 0; i < %s; i++) {" % nVar
451                 print "        " + type.key.copyCValue("datum.keys[i].%s" % type.key.type.to_string(), "%s[i]" % keyVar)
452                 if type.value:
453                     print "        " + type.value.copyCValue("datum.values[i].%s" % type.value.type.to_string(), "%s[i]" % valueVar)
454                 print "    }"
455                 if type.value:
456                     valueType = type.value.toAtomicType()
457                 else:
458                     valueType = "OVSDB_TYPE_VOID"
459                 print "    ovsdb_datum_sort_unique(&datum, %s, %s);" % (
460                     type.key.toAtomicType(), valueType)
461             print "    ovsdb_idl_txn_write(&row->header_, &%(s)s_columns[%(S)s_COL_%(C)s], &datum);" \
462                 % {'s': structName,
463                    'S': structName.upper(),
464                    'C': columnName.upper()}
465             print "}"
466
467         # Table columns.
468         print "\nstruct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % (
469             structName, structName.upper())
470         print """
471 static void\n%s_columns_init(void)
472 {
473     struct ovsdb_idl_column *c;\
474 """ % structName
475         for columnName, column in sorted(table.columns.iteritems()):
476             cs = "%s_col_%s" % (structName, columnName)
477             d = {'cs': cs, 'c': columnName, 's': structName}
478             print
479             print "    /* Initialize %(cs)s. */" % d
480             print "    c = &%(cs)s;" % d
481             print "    c->name = \"%(c)s\";" % d
482             print column.type.cInitType("    ", "c->type")
483             print "    c->parse = %(s)s_parse_%(c)s;" % d
484             print "    c->unparse = %(s)s_unparse_%(c)s;" % d
485         print "}"
486
487     # Table classes.
488     print "\f"
489     print "struct ovsdb_idl_table_class %stable_classes[%sN_TABLES] = {" % (prefix, prefix.upper())
490     for tableName, table in sorted(schema.tables.iteritems()):
491         structName = "%s%s" % (prefix, tableName.lower())
492         print "    {\"%s\"," % tableName
493         print "     %s_columns, ARRAY_SIZE(%s_columns)," % (
494             structName, structName)
495         print "     sizeof(struct %s)}," % structName
496     print "};"
497
498     # IDL class.
499     print "\nstruct ovsdb_idl_class %sidl_class = {" % prefix
500     print "    \"%s\", %stable_classes, ARRAY_SIZE(%stable_classes)" % (
501         schema.name, prefix, prefix)
502     print "};"
503
504     # global init function
505     print """
506 void
507 %sinit(void)
508 {
509     if (inited) {
510         return;
511     }
512     inited = true;
513 """ % prefix
514     for tableName, table in sorted(schema.tables.iteritems()):
515         structName = "%s%s" % (prefix, tableName.lower())
516         print "    %s_columns_init();" % structName
517     print "}"
518
519 def ovsdb_escape(string):
520     def escape(match):
521         c = match.group(0)
522         if c == '\0':
523             raise ovs.db.error.Error("strings may not contain null bytes")
524         elif c == '\\':
525             return '\\\\'
526         elif c == '\n':
527             return '\\n'
528         elif c == '\r':
529             return '\\r'
530         elif c == '\t':
531             return '\\t'
532         elif c == '\b':
533             return '\\b'
534         elif c == '\a':
535             return '\\a'
536         else:
537             return '\\x%02x' % ord(c)
538     return re.sub(r'["\\\000-\037]', escape, string)
539
540
541
542 def usage():
543     print """\
544 %(argv0)s: ovsdb schema compiler
545 usage: %(argv0)s [OPTIONS] COMMAND ARG...
546
547 The following commands are supported:
548   annotate SCHEMA ANNOTATIONS print SCHEMA combined with ANNOTATIONS
549   c-idl-header IDL            print C header file for IDL
550   c-idl-source IDL            print C source file for IDL implementation
551   nroff IDL                   print schema documentation in nroff format
552
553 The following options are also available:
554   -h, --help                  display this help message
555   -V, --version               display version information\
556 """ % {'argv0': argv0}
557     sys.exit(0)
558
559 if __name__ == "__main__":
560     try:
561         try:
562             options, args = getopt.gnu_getopt(sys.argv[1:], 'C:hV',
563                                               ['directory',
564                                                'help',
565                                                'version'])
566         except getopt.GetoptError, geo:
567             sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
568             sys.exit(1)
569             
570         for key, value in options:
571             if key in ['-h', '--help']:
572                 usage()
573             elif key in ['-V', '--version']:
574                 print "ovsdb-idlc (Open vSwitch) @VERSION@"
575             elif key in ['-C', '--directory']:
576                 os.chdir(value)
577             else:
578                 sys.exit(0)
579             
580         optKeys = [key for key, value in options]
581
582         if not args:
583             sys.stderr.write("%s: missing command argument "
584                              "(use --help for help)\n" % argv0)
585             sys.exit(1)
586
587         commands = {"annotate": (annotateSchema, 2),
588                     "c-idl-header": (printCIDLHeader, 1),
589                     "c-idl-source": (printCIDLSource, 1)}
590
591         if not args[0] in commands:
592             sys.stderr.write("%s: unknown command \"%s\" "
593                              "(use --help for help)\n" % (argv0, args[0]))
594             sys.exit(1)
595
596         func, n_args = commands[args[0]]
597         if len(args) - 1 != n_args:
598             sys.stderr.write("%s: \"%s\" requires %d arguments but %d "
599                              "provided\n"
600                              % (argv0, args[0], n_args, len(args) - 1))
601             sys.exit(1)
602
603         func(*args[1:])
604     except ovs.db.error.Error, e:
605         sys.stderr.write("%s: %s\n" % (argv0, e))
606         sys.exit(1)
607
608 # Local variables:
609 # mode: python
610 # End: