Looks Good to me.
On Wed, Mar 9, 2011 at 2:44 PM, Ben Pfaff <[email protected]> wrote: > It is conventional for Unix tools to read from standard input if "-" is > specified as a file name. It's easy for "ovs-ofctl add-flows" to behave > this way, too, so this commit implements it. > > Suggested-by: Paul Ingram <[email protected]> > --- > utilities/ovs-ofctl.8.in | 3 ++- > utilities/ovs-ofctl.c | 6 ++++-- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in > index 95b0884..3472cc1 100644 > --- a/utilities/ovs-ofctl.8.in > +++ b/utilities/ovs-ofctl.8.in > @@ -132,7 +132,8 @@ below. > . > .TP > \fBadd\-flows \fIswitch file\fR > -Add flow entries as described in \fIfile\fR to \fIswitch\fR's > +Add the flow entries listed in \fIfile\fR, or supplied on \fBstdin\fR > +if \fIfile\fR is \fB\-\fR, to \fIswitch\fR's > tables. Each line in \fIfile\fR is a flow entry in the format > described in \fBFlow Syntax\fR, below. > . > diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c > index a96b77a..f7605f7 100644 > --- a/utilities/ovs-ofctl.c > +++ b/utilities/ovs-ofctl.c > @@ -692,7 +692,7 @@ do_add_flows(int argc OVS_UNUSED, char *argv[]) > struct vconn *vconn; > FILE *file; > > - file = fopen(argv[2], "r"); > + file = !strcmp(argv[2], "-") ? stdin : fopen(argv[2], "r"); > if (file == NULL) { > ovs_fatal(errno, "%s: open", argv[2]); > } > @@ -707,7 +707,9 @@ do_add_flows(int argc OVS_UNUSED, char *argv[]) > } > vconn_close(vconn); > > - fclose(file); > + if (file != stdin) { > + fclose(file); > + } > } > > static void > -- > 1.7.1 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
