http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv ---------------------------------------------------------------------- diff --git a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv b/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv deleted file mode 100644 index 8c8ba3e..0000000 --- a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv +++ /dev/null @@ -1,5 +0,0 @@ -C function,Java Method,Java Annotation -function1,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#methodWithMapping,function1 -function2,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#anotherMethodWithMapping,function2 -,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#methodWithoutMapping, -function4,,
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv ---------------------------------------------------------------------- diff --git a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv b/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv deleted file mode 100644 index 082f623..0000000 --- a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv +++ /dev/null @@ -1,2 +0,0 @@ -C function,Java Method,Java Annotation -function1,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#methodWithMapping,function1 http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/build.xml ---------------------------------------------------------------------- diff --git a/design/build.xml b/design/build.xml deleted file mode 100644 index e884b68..0000000 --- a/design/build.xml +++ /dev/null @@ -1,90 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project name="Qpid Proton Design" default="dist" basedir="."> - <description> - simple example build file - </description> - - <!-- global properties for this build --> - <property name="src" location="src"/> - <property name="build" location="build"/> - <property name="dist" location="dist"/> - <property name="classes" location="${build}/classes"/> - <property name="docs" location="${build}/docs"/> - <property name="umlgraph.jar" location="/usr/share/java/umlgraph.jar"/> - - <target name="init"> - <tstamp/> - <mkdir dir="${classes}"/> - </target> - - <target name="compile" depends="init" description="compile the source "> - <javac srcdir="${src}" destdir="${classes}"/> - </target> - - <target name="uml"> - <property name="uml.dir" value="${docs}/uml"/> - <mkdir dir="${uml.dir}"/> - <path id="uml.source.path"> - <pathelement path="${src}/"/> - </path> - <javadoc sourcepathref="uml.source.path" packagenames="*" package="true"> - <doclet name="org.umlgraph.doclet.UmlGraph" path="${umlgraph.jar}"> - <param name="-d" value="${uml.dir}"/> - </doclet> - </javadoc> - <apply executable="dot" dest="${uml.dir}" parallel="false"> - <arg value="-Tpng"/> - <arg value="-o"/> - <targetfile/> - <srcfile/> - <fileset dir="${uml.dir}" includes="*.dot"/> - <mapper type="glob" from="*.dot" to="*.png"/> - </apply> - </target> - - <target name="apidoc"> - <javadoc destdir="${docs}/api" author="true" version="true" use="true" - windowtitle="Qpid Proton API"> - - <fileset dir="src" defaultexcludes="yes"> - <include name="proton/**.java"/> - </fileset> - - <doctitle><![CDATA[<h1>Qpid Proton</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2011 Rafael Schloming All Rights Reserved.</i>]]></bottom> - <tag name="todo" scope="all" description="To do:"/> - <link offline="true" href="http://download.oracle.com/javase/6/docs/api/" packagelistLoc="C:\tmp"/> - <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/> - </javadoc> - </target> - - <target name="doc" depends="uml,apidoc"/> - - <target name="dist" depends="compile,doc" description="generate the distribution"> - <mkdir dir="${dist}/lib"/> - - <jar jarfile="${dist}/lib/qpidproton.jar" basedir="${classes}"/> - <zip destfile="${dist}/docs.zip" basedir="${docs}"/> - <zip destfile="${dist}/srcs.zip" basedir="${basedir}" excludes="build/**,dist/**"/> - </target> - - <target name="clean" description="clean up" > - <delete dir="${build}"/> - <delete dir="${dist}"/> - </target> -</project> http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/proton_objects.dia ---------------------------------------------------------------------- diff --git a/design/proton_objects.dia b/design/proton_objects.dia deleted file mode 100644 index 4fc2634..0000000 Binary files a/design/proton_objects.dia and /dev/null differ http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Accepted.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Accepted.java b/design/src/proton/Accepted.java deleted file mode 100644 index 246eb6c..0000000 --- a/design/src/proton/Accepted.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Accepted - * - * @hidden - * - */ - -public interface Accepted extends Outcome -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Connection.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Connection.java b/design/src/proton/Connection.java deleted file mode 100644 index a7f4af7..0000000 --- a/design/src/proton/Connection.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - -import java.util.Iterator; - - -/** - * Connection - * - * @opt operations - * @opt types - * - * @composed 1 - "0..n" Session - * @composed 1 - "0..?" Transport - * - */ - -public interface Connection extends Endpoint -{ - - /** - * transition local state to ACTIVE - */ - public void open(); - - /** - * transition local state to CLOSED - */ - public void close(); - - /** - * @return a newly created session - */ - public Session session(); - - /** - * @return a newly created transport - */ - public Transport transport(); - - /** - * @return iterator for endpoints matching the specified local and - * remote states - */ - public Iterator<Endpoint> endpoints(Endpoint.State local, Endpoint.State remote); - - /** - * @return iterator for incoming link endpoints with pending - * transfers - */ - public Iterator<Receiver> incoming(); - - /** - * @return iterator for unblocked outgoing link endpoints with - * offered credits - */ - public Iterator<Sender> outgoing(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Delivery.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Delivery.java b/design/src/proton/Delivery.java deleted file mode 100644 index f68b020..0000000 --- a/design/src/proton/Delivery.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Delivery - * - * @opt operations - * @opt types - * - * @assoc - local 0..1 DeliveryState - * @assoc - remote 0..1 DeliveryState - * - * @todo deliveries need to track important link state (source and - * targets) at the point that they were created - * - */ - -public interface Delivery -{ - - public byte[] getTag(); - - public Link getLink(); - - public DeliveryState getLocalState(); - - public DeliveryState getRemoteState(); - - public boolean remoteSettled(); - - public int getMessageFormat(); - - /** - * updates the state of the delivery - * - * @param state the new delivery state - */ - public void disposition(DeliveryState state); - - /** - * settle the delivery - */ - public void settle(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/DeliveryBuffer.java ---------------------------------------------------------------------- diff --git a/design/src/proton/DeliveryBuffer.java b/design/src/proton/DeliveryBuffer.java deleted file mode 100644 index bdd592e..0000000 --- a/design/src/proton/DeliveryBuffer.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * DeliveryBuffer - * - * @opt operations - * @opt attributes - * @opt types - * - * @composed 1 - "0..n" Delivery - * - */ - -public interface DeliveryBuffer -{ - - int next = 0; - - public int getCapacity(); - - public int getSize(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/DeliveryState.java ---------------------------------------------------------------------- diff --git a/design/src/proton/DeliveryState.java b/design/src/proton/DeliveryState.java deleted file mode 100644 index 50d23e3..0000000 --- a/design/src/proton/DeliveryState.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * DeliveryState - * - */ - -public interface DeliveryState -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Endpoint.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Endpoint.java b/design/src/proton/Endpoint.java deleted file mode 100644 index 6d7a997..0000000 --- a/design/src/proton/Endpoint.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Endpoint - * - * @opt operations - * @opt types - * - * @assoc - local 1 Endpoint.State - * @assoc - remote 1 Endpoint.State - * @assoc - local 0..1 Endpoint.Error - * @assoc - remote 0..1 Endpoint.Error - */ - -public interface Endpoint -{ - - /** - * Represents the state of a communication endpoint. - */ - public static final class State { - - private String name; - - private State(String name) - { - this.name = name; - } - - public String toString() - { - return name; - } - - }; - - public static final State UNINIT = new State("UNINIT"); - public static final State ACTIVE = new State("ACTIVE"); - public static final State CLOSED = new State("CLOSED"); - - /** - * Holds information about an endpoint error. - */ - public static final class Error { - - private String name; - private String description; - - public Error(String name, String description) - { - this.name = name; - this.description = description; - } - - public Error(String name) - { - this(name, null); - } - - public String toString() - { - if (description == null) - { - return name; - } - else - { - return String.format("%s -- %s", name, description); - } - } - } - - /** - * @return the local endpoint state - */ - public State getLocalState(); - - /** - * @return the remote endpoint state (as last communicated) - */ - public State getRemoteState(); - - /** - * @return the local endpoint error, or null if there is none - */ - public Error getLocalError(); - - /** - * @return the remote endpoint error, or null if there is none - */ - public Error getRemoteError(); - - /** - * free the endpoint and any associated resources - */ - public void free(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Link.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Link.java b/design/src/proton/Link.java deleted file mode 100644 index ec80b62..0000000 --- a/design/src/proton/Link.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - -import java.util.Iterator; - - -/** - * Link - * - * @opt operations - * @opt types - * - * @assoc 1 - n Delivery - * - * @todo make links able to exist independently from - * sessions/connections and allow to migrate - * - */ - -public interface Link extends Endpoint -{ - - /** - * transition local state to ACTIVE - */ - public void attach(); - - /** - * transition local state to CLOSED - */ - public void detach(); - - /** - * @param tag a tag for the delivery - * - * @return a Delivery object - */ - public Delivery delivery(byte[] tag); - - /** - * @return the unsettled deliveries for this link - */ - public Iterator<Delivery> unsettled(); - - /** - * Advances the current delivery to the next delivery on the link. - * - * @return the next delivery or null if there is none - */ - public Delivery next(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Modified.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Modified.java b/design/src/proton/Modified.java deleted file mode 100644 index 1f07cb0..0000000 --- a/design/src/proton/Modified.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Modified - * - * @hidden - * - */ - -public interface Modified extends Outcome -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Outcome.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Outcome.java b/design/src/proton/Outcome.java deleted file mode 100644 index d0a4064..0000000 --- a/design/src/proton/Outcome.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Outcome - * - * @hidden - * - */ - -public interface Outcome extends DeliveryState -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Received.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Received.java b/design/src/proton/Received.java deleted file mode 100644 index 37856bf..0000000 --- a/design/src/proton/Received.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Received - * - * @hidden - * - */ - -public interface Received extends DeliveryState -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Receiver.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Receiver.java b/design/src/proton/Receiver.java deleted file mode 100644 index f46bfa4..0000000 --- a/design/src/proton/Receiver.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Receiver - * - * @opt operations - * @opt types - * - */ - -public interface Receiver extends Link -{ - - /** - * issue the specified number of credits - */ - public void flow(int credits); - - /** - * Receive message data for the current delivery. - * - * @param bytes the destination array where the message data is written - * @param offset the index to begin writing into the array - * @param size the maximum number of bytes to write - * - * @return the number of bytes written or -1 if there is no more - * message data for the current delivery - */ - public int recv(byte[] bytes, int offset, int size); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Rejected.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Rejected.java b/design/src/proton/Rejected.java deleted file mode 100644 index 92f1ec4..0000000 --- a/design/src/proton/Rejected.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Rejected - * - * @hidden - * - */ - -public interface Rejected extends Outcome -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Released.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Released.java b/design/src/proton/Released.java deleted file mode 100644 index e480ef7..0000000 --- a/design/src/proton/Released.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Released - * - * @hidden - * - */ - -public interface Released extends Outcome -{ - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Sender.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Sender.java b/design/src/proton/Sender.java deleted file mode 100644 index 36bd68d..0000000 --- a/design/src/proton/Sender.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Sender - * - * @opt operations - * @opt types - * - */ - -public interface Sender extends Link -{ - - /** - * indicates pending deliveries - * - * @param credits the number of pending deliveries - * @todo is this absolute or cumulative? - */ - public void offer(int credits); - - /** - * Sends message data for the current delivery. - * - * @param bytes the message data - */ - public void send(byte[] bytes); - - /** - * Abort the current delivery. - */ - public void abort(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Session.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Session.java b/design/src/proton/Session.java deleted file mode 100644 index b6ae6f9..0000000 --- a/design/src/proton/Session.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - -import java.util.Iterator; - - -/** - * Session - * - * @opt operations - * @opt types - * - * @composed 1 - "0..n" Link - * @composed 1 incoming 1 DeliveryBuffer - * @composed 1 outgoing 1 DeliveryBuffer - * - */ - -public interface Session extends Endpoint -{ - - /** - * transition local state to ACTIVE - */ - public void begin(); - - /** - * transition local state to CLOSED - */ - public void end(); - - /** - * @return a newly created outgoing link - */ - public Sender sender(); - - /** - * @return a newly created incoming link - */ - public Receiver receiver(); - - /** - * @see Connection#endpoints(Endpoint.State, Endpoint.State) - */ - public Iterator<Endpoint> endpoints(Endpoint.State local, Endpoint.State remote); - - /** - * @see Connection#incoming() - */ - public Iterator<Receiver> incoming(); - - /** - * @see Connection#outgoing() - */ - public Iterator<Sender> outgoing(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/Transport.java ---------------------------------------------------------------------- diff --git a/design/src/proton/Transport.java b/design/src/proton/Transport.java deleted file mode 100644 index 0ff89ac..0000000 --- a/design/src/proton/Transport.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package proton; - - -/** - * Transport - * - * @opt operations - * @opt types - * - */ - -public interface Transport extends Endpoint -{ - - /** - * @param bytes input bytes for consumption - * @param offset the offset within bytes where input begins - * @param size the number of bytes available for input - * - * @return the number of bytes consumed - */ - public int input(byte[] bytes, int offset, int size); - - /** - * @param bytes array for output bytes - * @param offset the offset within bytes where output begins - * @param size the number of bytes available for output - * - * @return the number of bytes written - */ - public int output(byte[] bytes, int offset, int size); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/design/src/proton/package.html ---------------------------------------------------------------------- diff --git a/design/src/proton/package.html b/design/src/proton/package.html deleted file mode 100644 index c72c78f..0000000 --- a/design/src/proton/package.html +++ /dev/null @@ -1,122 +0,0 @@ -<html> - <body> - <p> - Connections are the primary unit of resource management. - Sessions and Links are components of connections. When the - Connection is freed/discarded, any resources associated with - the Sessions and Links are automatically destroyed or discarded - as well. - </p> - - <p> - Each of the Connection, Session, and Link endpoints share a - common state model. Note that although this follows the same - pattern as the protocol state model for open/close, begin/end, - and attach/detach, this does not necessarily correspond one to - one to the protocol state model for endpoints. For example the - engine implementation may detach/reattach a link endpoint - without visibly changing the external state. - </p> - - <p> - The state of each endpoint is divided into two parts, one - reflecting the state of the local endpoint, and the other - reflecting the state of the remote endpoint as last - communicated. - </p> - - <pre> - LOCAL: - UNINIT - ACTIVE - CLOSED - - REMOTE: - UNINIT - ACTIVE - CLOSED - </pre> - - <p>In total there are 9 possible states:</p> - - <pre> - LOCAL REMOTE Example - ------------------------------------------------------------------------- - UNINIT UNINIT A newly created connection. - - UNINIT ACTIVE A remotely initiated connection - prior to full establishment. - - UNINIT CLOSED A remotely initiated connection that - has been closed prior to full - establishment. - - ACTIVE UNINIT A locally initiated connection prior - to full establishment. - - ACTIVE ACTIVE A fully established connection. - - ACTIVE CLOSED A remotely terminated connection. - - CLOSED UNINIT A locally initiated connection that - has been closed prior to full - establishment. - - CLOSED ACTIVE A locally terminated connection. - - CLOSED CLOSED A fully terminated connection. - </pre> - - <p> - Additionally each endpoint has an error slot which may be filled - with additional information regarding error conditions, e.g. why - the remote endpoint was transitioned to CLOSED. - </p> - - <h3>Questions:</h3> - - <ul> - <li>The transfer buffer class may not necessarily be explicitly part - of the external interface, e.g. it could be absorbed into the - session interface.</li> - <li>how do we confirm acheiving active/active without iterating - over all active/active endpoints? - <ul> - <li>add an ignore/interest flag as part of generic endpoint state?</li> - <li>add pending state to local state?</li> - </ul> - </li> - <li>what are credits exactly? - <ul> - <li>how does synchronous get work? - <ul><li>implies credit unit needs to be messages?</li></ul> - <li>credits may not correspond exactly with on-the-wire credits due - to local buffering</li> - </ul> - </li> - <li>how would 0-x impls work given that we're passing bytes directly to send? - <ul> - <li>have a generic property get/set API? - <ul><li>this could address per transfer flags as well</li></ul> - </li> - </ul> - </li> - <li>how do large messages work? - <ul><li>does send need a done flag for multiple transfers?</li></ul> - </li> - <li>how does resume work?</li> - <li>how does abort work?</li> - <li>how do we send settled? - <ul> - <li>just call settle on the returned transfer, the engine MUST optimize</li> - </ul> - </li> - <li> - how do we deal with send and receive modes on individual transfers? - <ul><li>could just twiddle the link ones and set them on the - transfer frame if they differ from what they were when the - attach was made</li></ul> - </li> - </ul> - </body> -</html> http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/docs/markdown/engine/engine.md ---------------------------------------------------------------------- diff --git a/docs/markdown/engine/engine.md b/docs/markdown/engine/engine.md deleted file mode 100644 index b1a6f60..0000000 --- a/docs/markdown/engine/engine.md +++ /dev/null @@ -1,74 +0,0 @@ -Proton's Engine is a stateful component with a low-level API that allows an -application to communicate using AMQP. This document gives a high level overview -of the Engine's design, intended to be read by application developers intending -to use it. - -The Engine is built around the concept of a protocol engine. The idea behind a -protocol engine is to capture all the complex details of implementing a given -protocol in a way that is as decoupled as possible from OS details such as I/O -and threading models. The result is a highly portable and easily embedded -component that provides a full protocol implementation. - - -The Engine API --------------- - -The Engine contains in-memory representations of AMQP entities such as -Connection, Session and Delivery. These are manipulated via its API, which -consists of two main parts. - -- The *control and query API*, commonly referred to as *The Top Half*, which - offers functions to directly create, modify and query the Connections, - Sessions etc. - -- The *transport API*, commonly referred to as *The Bottom Half*, which contains - a small set of functions to operate on the AMQP entities therein by accepting - binary AMQP input and producing binary AMQP output. The Engine's transport - layer can be thought of as transforming a *queue of bytes*, therefore the API - is expressed in terms of input appended to the *tail* and output fetched from - the *head*. - - -Typical Engine usage --------------------- - -The diagram below shows how the Engine is typically used by an application. The -socket's remote peer is serviced by another AMQP application, which may (or may -not) use Proton. - -<pre> -<![CDATA[ - - +------------ + +---------------+ - | | | | - | Application |--------->| Engine | - | business | | "Top Half" | - | logic | | Control and | - | |<---------| query API | - | | | | - | | +---------------+ - | | | - +-------------+ +-------------+ +---------------+ - | | Input | | Tail | Engine | - | |--------->| |--------->| "Bottom half" | - | Socket | | Application | | Transport API | - | |<---------| I/O layer |<---------| | - | | Output | | Head | | - +-------------+ +-------------+ +---------------+ -]]> -</pre> - -For maximum flexibility, the Engine is not multi-threaded. It is therefore -typical for an application thread to loop continuously, repeatedly calling the -Top Half and Bottom Half functions. - - -Implementations ---------------- - -Implementations of the Engine currently exist in C and Java. Bindings exist from -several languages (e.g. Ruby, Python, Java Native Interface) to the C Engine. - -For more information see the documentation in the code. - - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index 4d744d2..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set (ProtonCpp_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - -# Set result to a native search path -macro(set_search_path result) # args after result are directories or search paths. - set(${result} ${ARGN}) - if (UNIX) - string(REPLACE ";" ":" ${result} "${${result}}") # native search path separators. - endif() - file(TO_NATIVE_PATH "${${result}}" ${result}) # native slash separators -endmacro() - -# Some non-python examples use exampletest.py to drive their self-tests. -set_search_path(EXAMPLE_PYTHONPATH "${CMAKE_CURRENT_SOURCE_DIR}" "$ENV{PYTHON_PATH}") -set(EXAMPLE_ENV "PYTHONPATH=${EXAMPLE_PYTHONPATH}") - -add_subdirectory(c) -add_subdirectory(go) -if (BUILD_CPP) - add_subdirectory(cpp) -endif() http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/ProtonConfig.cmake ---------------------------------------------------------------------- diff --git a/examples/ProtonConfig.cmake b/examples/ProtonConfig.cmake deleted file mode 100644 index e910082..0000000 --- a/examples/ProtonConfig.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Note that this file is used *only* when building the examples within -# the proton source tree not when the examples are installed separately -# from it (for example in an OS distribution package). -# -# So if you find this file installed on your system something went wrong -# with the packaging and/or package installation. -# -# For a packaged installation the equivalent file is created by the source -# tree build and installed in the appropriate place for cmake on that system. - -set (Proton_VERSION ${PN_VERSION}) -set (Proton_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/proton-c/include) -set (Proton_LIBRARIES qpid-proton) -set (Proton_FOUND True) http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/ProtonCppConfig.cmake ---------------------------------------------------------------------- diff --git a/examples/ProtonCppConfig.cmake b/examples/ProtonCppConfig.cmake deleted file mode 100644 index e23d134..0000000 --- a/examples/ProtonCppConfig.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Note that this file is used *only* when building the examples within -# the proton source tree not when the examples are installed separately -# from it (for example in an OS distribution package). -# -# So if you find this file installed on your system something went wrong -# with the packaging and/or package installation. -# -# For a packaged installation the equivalent file is created by the source -# tree build and installed in the appropriate place for cmake on that system. - -set (ProtonCpp_VERSION ${PN_VERSION}) -set (ProtonCpp_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/proton-c/include ${CMAKE_SOURCE_DIR}/proton-c/bindings/cpp/include) -set (ProtonCpp_LIBRARIES qpid-proton-cpp) -set (ProtonCpp_FOUND True) http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt deleted file mode 100644 index 0d0c7e9..0000000 --- a/examples/c/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -find_package(Proton REQUIRED) -include(CheckCCompilerFlag) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) - -add_subdirectory(proactor) -add_subdirectory(messenger) -add_subdirectory(reactor) http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/include/pncompat/internal/LICENSE ---------------------------------------------------------------------- diff --git a/examples/c/include/pncompat/internal/LICENSE b/examples/c/include/pncompat/internal/LICENSE deleted file mode 100644 index 99efb42..0000000 --- a/examples/c/include/pncompat/internal/LICENSE +++ /dev/null @@ -1,33 +0,0 @@ -Free Getopt -Copyright (c)2002-2003 Mark K. Kim -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - * Neither the original author of this software nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/include/pncompat/internal/getopt.c ---------------------------------------------------------------------- diff --git a/examples/c/include/pncompat/internal/getopt.c b/examples/c/include/pncompat/internal/getopt.c deleted file mode 100644 index 7ef9a68..0000000 --- a/examples/c/include/pncompat/internal/getopt.c +++ /dev/null @@ -1,250 +0,0 @@ -/***************************************************************************** -* getopt.c - competent and free getopt library. -* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $ -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "getopt.h" - - -static const char* ID = "$Id: getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $"; - - -char* optarg = NULL; -int optind = 0; -int opterr = 1; -int optopt = '?'; - - -static char** prev_argv = NULL; /* Keep a copy of argv and argc to */ -static int prev_argc = 0; /* tell if getopt params change */ -static int argv_index = 0; /* Option we're checking */ -static int argv_index2 = 0; /* Option argument we're checking */ -static int opt_offset = 0; /* Index into compounded "-option" */ -static int dashdash = 0; /* True if "--" option reached */ -static int nonopt = 0; /* How many nonopts we've found */ - -static void increment_index() -{ - /* Move onto the next option */ - if(argv_index < argv_index2) - { - while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-' - && argv_index < argv_index2+1); - } - else argv_index++; - opt_offset = 1; -} - - -/* -* Permutes argv[] so that the argument currently being processed is moved -* to the end. -*/ -static int permute_argv_once() -{ - /* Movability check */ - if(argv_index + nonopt >= prev_argc) return 1; - /* Move the current option to the end, bring the others to front */ - else - { - char* tmp = prev_argv[argv_index]; - - /* Move the data */ - memmove(&prev_argv[argv_index], &prev_argv[argv_index+1], - sizeof(char**) * (prev_argc - argv_index - 1)); - prev_argv[prev_argc - 1] = tmp; - - nonopt++; - return 0; - } -} - - -int getopt(int argc, char** argv, char* optstr) -{ - int c = 0; - - /* If we have new argv, reinitialize */ - if(prev_argv != argv || prev_argc != argc) - { - /* Initialize variables */ - prev_argv = argv; - prev_argc = argc; - argv_index = 1; - argv_index2 = 1; - opt_offset = 1; - dashdash = 0; - nonopt = 0; - } - - /* Jump point in case we want to ignore the current argv_index */ - getopt_top: - - /* Misc. initializations */ - optarg = NULL; - - /* Dash-dash check */ - if(argv[argv_index] && !strcmp(argv[argv_index], "--")) - { - dashdash = 1; - increment_index(); - } - - /* If we're at the end of argv, that's it. */ - if(argv[argv_index] == NULL) - { - c = -1; - } - /* Are we looking at a string? Single dash is also a string */ - else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-")) - { - /* If we want a string... */ - if(optstr[0] == '-') - { - c = 1; - optarg = argv[argv_index]; - increment_index(); - } - /* If we really don't want it (we're in POSIX mode), we're done */ - else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT")) - { - c = -1; - - /* Everything else is a non-opt argument */ - nonopt = argc - argv_index; - } - /* If we mildly don't want it, then move it back */ - else - { - if(!permute_argv_once()) goto getopt_top; - else c = -1; - } - } - /* Otherwise we're looking at an option */ - else - { - char* opt_ptr = NULL; - - /* Grab the option */ - c = argv[argv_index][opt_offset++]; - - /* Is the option in the optstr? */ - if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c); - else opt_ptr = strchr(optstr, c); - /* Invalid argument */ - if(!opt_ptr) - { - if(opterr) - { - fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); - } - - optopt = c; - c = '?'; - - /* Move onto the next option */ - increment_index(); - } - /* Option takes argument */ - else if(opt_ptr[1] == ':') - { - /* ie, -oARGUMENT, -xxxoARGUMENT, etc. */ - if(argv[argv_index][opt_offset] != '\0') - { - optarg = &argv[argv_index][opt_offset]; - increment_index(); - } - /* ie, -o ARGUMENT (only if it's a required argument) */ - else if(opt_ptr[2] != ':') - { - /* One of those "you're not expected to understand this" moment */ - if(argv_index2 < argv_index) argv_index2 = argv_index; - while(argv[++argv_index2] && argv[argv_index2][0] == '-'); - optarg = argv[argv_index2]; - - /* Don't cross into the non-option argument list */ - if(argv_index2 + nonopt >= prev_argc) optarg = NULL; - - /* Move onto the next option */ - increment_index(); - } - else - { - /* Move onto the next option */ - increment_index(); - } - - /* In case we got no argument for an option with required argument */ - if(optarg == NULL && opt_ptr[2] != ':') - { - optopt = c; - c = '?'; - - if(opterr) - { - fprintf(stderr,"%s: option requires an argument -- %c\n", - argv[0], optopt); - } - } - } - /* Option does not take argument */ - else - { - /* Next argv_index */ - if(argv[argv_index][opt_offset] == '\0') - { - increment_index(); - } - } - } - - /* Calculate optind */ - if(c == -1) - { - optind = argc - nonopt; - } - else - { - optind = argv_index; - } - - return c; -} - - -/* vim:ts=3 -*/ http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/include/pncompat/internal/getopt.h ---------------------------------------------------------------------- diff --git a/examples/c/include/pncompat/internal/getopt.h b/examples/c/include/pncompat/internal/getopt.h deleted file mode 100644 index 0b78650..0000000 --- a/examples/c/include/pncompat/internal/getopt.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** -* getopt.h - competent and free getopt library. -* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $ -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#ifndef GETOPT_H_ -#define GETOPT_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern char* optarg; -extern int optind; -extern int opterr; -extern int optopt; - -int getopt(int argc, char** argv, char* optstr); - - -#ifdef __cplusplus -} -#endif - - -#endif /* GETOPT_H_ */ - - -/* vim:ts=3 -*/ http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/include/pncompat/misc_defs.h ---------------------------------------------------------------------- diff --git a/examples/c/include/pncompat/misc_defs.h b/examples/c/include/pncompat/misc_defs.h deleted file mode 100644 index 90b0d4e..0000000 --- a/examples/c/include/pncompat/misc_defs.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef PNCOMAPT_MISC_DEFS_H -#define PNCOMAPT_MISC_DEFS_H - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#if defined(qpid_proton_EXPORTS) -#error This include file is not for use in the main proton library -#endif - -/* - * Platform neutral definitions. Only intended for use by Proton - * examples and test/debug programs. - * - * This file and any related support files may change or be removed - * at any time. - */ - -// getopt() - -#include <proton/types.h> - -#if defined(__IBMC__) -# include <stdlib.h> -#elif !defined(_WIN32) || defined (__CYGWIN__) -# include <getopt.h> -#else -# include "internal/getopt.h" -#endif - -pn_timestamp_t time_now(void); - -#endif /* PNCOMPAT_MISC_DEFS_H */ http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/include/pncompat/misc_funcs.inc ---------------------------------------------------------------------- diff --git a/examples/c/include/pncompat/misc_funcs.inc b/examples/c/include/pncompat/misc_funcs.inc deleted file mode 100644 index 821aaf4..0000000 --- a/examples/c/include/pncompat/misc_funcs.inc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file provides the functions for "misc_defs.h" in the form of - * included code, as opposed to a separate library or object - * dependency. In the absence of portable "pragma weak" compiler - * directives, this provides a simple workaround. - * - * Usage for a single compilation unit: - * - * #include "pncompat/misc_funcs.inc" - * - * Usage for multiple combined compilation units: chose one to include - * "pncompat/misc_funcs.inc" as above and in each other unit needing the - * definitions use - * - * #include "pncompat/misc_defs.h" - * - */ - -#include "misc_defs.h" - -#if defined(_WIN32) && ! defined(__CYGWIN__) -#include "pncompat/internal/getopt.c" -#endif - -#if defined(_WIN32) && ! defined(__CYGWIN__) -#include <windows.h> -pn_timestamp_t time_now(void) -{ - FILETIME now; - ULARGE_INTEGER t; - GetSystemTimeAsFileTime(&now); - t.u.HighPart = now.dwHighDateTime; - t.u.LowPart = now.dwLowDateTime; - // Convert to milliseconds and adjust base epoch - return t.QuadPart / 10000 - 11644473600000; -} -#else -#include <sys/time.h> -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> -pn_timestamp_t time_now(void) -{ - struct timeval now; - if (gettimeofday(&now, NULL)) {fprintf(stderr, "gettimeofday failed\n"); abort();} - return ((pn_timestamp_t)now.tv_sec) * 1000 + (now.tv_usec / 1000); -} -#endif http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/messenger/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/c/messenger/CMakeLists.txt b/examples/c/messenger/CMakeLists.txt deleted file mode 100644 index d4fec71..0000000 --- a/examples/c/messenger/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -find_package(Proton REQUIRED) - -set (messenger-examples - recv.c - send.c - recv-async.c - send-async.c - ) - -set_source_files_properties ( - ${messenger-examples} - PROPERTIES - COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS} ${LINK_TIME_OPTIMIZATION}" - ) - -if (BUILD_WITH_CXX) - set_source_files_properties ( - ${messenger-examples} - PROPERTIES LANGUAGE CXX - ) -endif (BUILD_WITH_CXX) - -add_executable(recv recv.c) -add_executable(send send.c) -add_executable(recv-async recv-async.c) -add_executable(send-async send-async.c) - -include_directories(${Proton_INCLUDE_DIRS}) - -target_link_libraries(recv ${Proton_LIBRARIES}) -target_link_libraries(send ${Proton_LIBRARIES}) -target_link_libraries(recv-async ${Proton_LIBRARIES}) -target_link_libraries(send-async ${Proton_LIBRARIES}) http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/messenger/recv-async.c ---------------------------------------------------------------------- diff --git a/examples/c/messenger/recv-async.c b/examples/c/messenger/recv-async.c deleted file mode 100644 index 1f49166..0000000 --- a/examples/c/messenger/recv-async.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -// This is a re-implementation of recv.c using non-blocking/asynchronous calls. - -#include "proton/message.h" -#include "proton/messenger.h" - -#include "pncompat/misc_funcs.inc" -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> - -#if EMSCRIPTEN -#include <emscripten.h> -#endif - -pn_message_t * message; -pn_messenger_t * messenger; - -#define check(messenger) \ - { \ - if(pn_messenger_errno(messenger)) \ - { \ - die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \ - } \ - } \ - -void die(const char *file, int line, const char *message) -{ - fprintf(stderr, "%s:%i: %s\n", file, line, message); - exit(1); -} - -void usage(void) -{ - printf("Usage: recv [options] <addr>\n"); - printf("-c \tPath to the certificate file.\n"); - printf("-k \tPath to the private key file.\n"); - printf("-p \tPassword for the private key.\n"); - printf("<addr>\tAn address.\n"); - exit(0); -} - -void process(void) { - while(pn_messenger_incoming(messenger)) - { - pn_messenger_get(messenger, message); - check(messenger); - - { - pn_tracker_t tracker = pn_messenger_incoming_tracker(messenger); - char buffer[1024]; - size_t buffsize = sizeof(buffer); - const char* subject = pn_message_get_subject(message); - pn_data_t* body = pn_message_body(message); - pn_data_format(body, buffer, &buffsize); - - printf("Address: %s\n", pn_message_get_address(message)); - printf("Subject: %s\n", subject ? subject : "(no subject)"); - printf("Content: %s\n", buffer); - - pn_messenger_accept(messenger, tracker, 0); - } - } -} - -#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler. -void pump(int fd, void* userData) { - while (pn_messenger_work(messenger, 0) >= 0) { - process(); - } -} - -void onclose(int fd, void* userData) { - process(); -} - -void onerror(int fd, int errno, const char* msg, void* userData) { - printf("error callback fd = %d, errno = %d, msg = %s\n", fd, errno, msg); -} -#endif - -int main(int argc, char** argv) -{ - char* certificate = NULL; - char* privatekey = NULL; - char* password = NULL; - char* address = (char *) "amqp://~0.0.0.0"; - int c; - - message = pn_message(); - messenger = pn_messenger(NULL); - pn_messenger_set_blocking(messenger, false); // Needs to be set non-blocking to behave asynchronously. - - opterr = 0; - - while((c = getopt(argc, argv, "hc:k:p:")) != -1) - { - switch(c) - { - case 'h': - usage(); - break; - - case 'c': certificate = optarg; break; - case 'k': privatekey = optarg; break; - case 'p': password = optarg; break; - - case '?': - if (optopt == 'c' || - optopt == 'k' || - optopt == 'p') - { - fprintf(stderr, "Option -%c requires an argument.\n", optopt); - } - else if(isprint(optopt)) - { - fprintf(stderr, "Unknown option `-%c'.\n", optopt); - } - else - { - fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); - } - return 1; - default: - abort(); - } - } - - if (optind < argc) - { - address = argv[optind]; - } - - /* load the various command line options if they're set */ - if(certificate) - { - pn_messenger_set_certificate(messenger, certificate); - } - - if(privatekey) - { - pn_messenger_set_private_key(messenger, privatekey); - } - - if(password) - { - pn_messenger_set_password(messenger, password); - } - - pn_messenger_start(messenger); - check(messenger); - - pn_messenger_subscribe(messenger, address); - check(messenger); - - pn_messenger_recv(messenger, -1); // Set to receive as many messages as messenger can buffer. - -#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler. - emscripten_set_socket_error_callback(NULL, onerror); - - emscripten_set_socket_open_callback(NULL, pump); - emscripten_set_socket_connection_callback(NULL, pump); - emscripten_set_socket_message_callback(NULL, pump); - emscripten_set_socket_close_callback(NULL, onclose); -#else // For native compiler. - while (1) { - pn_messenger_work(messenger, -1); // Block indefinitely until there has been socket activity. - process(); - } -#endif - - return 0; -} - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/messenger/recv.c ---------------------------------------------------------------------- diff --git a/examples/c/messenger/recv.c b/examples/c/messenger/recv.c deleted file mode 100644 index 16e8321..0000000 --- a/examples/c/messenger/recv.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "proton/message.h" -#include "proton/messenger.h" - -#include "pncompat/misc_funcs.inc" -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> - -#define check(messenger) \ - { \ - if(pn_messenger_errno(messenger)) \ - { \ - die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \ - } \ - } \ - -void die(const char *file, int line, const char *message) -{ - fprintf(stderr, "%s:%i: %s\n", file, line, message); - exit(1); -} - -void usage(void) -{ - printf("Usage: recv [options] <addr>\n"); - printf("-c \tPath to the certificate file.\n"); - printf("-k \tPath to the private key file.\n"); - printf("-p \tPassword for the private key.\n"); - printf("<addr>\tAn address.\n"); - exit(0); -} - -int main(int argc, char** argv) -{ - char* certificate = NULL; - char* privatekey = NULL; - char* password = NULL; - char* address = (char *) "amqp://~0.0.0.0"; - int c; - - pn_message_t * message; - pn_messenger_t * messenger; - - message = pn_message(); - messenger = pn_messenger(NULL); - - opterr = 0; - - while((c = getopt(argc, argv, "hc:k:p:")) != -1) - { - switch(c) - { - case 'h': - usage(); - break; - - case 'c': certificate = optarg; break; - case 'k': privatekey = optarg; break; - case 'p': password = optarg; break; - - case '?': - if(optopt == 'c' || - optopt == 'k' || - optopt == 'p') - { - fprintf(stderr, "Option -%c requires an argument.\n", optopt); - } - else if(isprint(optopt)) - { - fprintf(stderr, "Unknown option `-%c'.\n", optopt); - } - else - { - fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); - } - return 1; - default: - abort(); - } - } - - if (optind < argc) - { - address = argv[optind]; - } - - /* load the various command line options if they're set */ - if(certificate) - { - pn_messenger_set_certificate(messenger, certificate); - } - - if(privatekey) - { - pn_messenger_set_private_key(messenger, privatekey); - } - - if(password) - { - pn_messenger_set_password(messenger, password); - } - - pn_messenger_start(messenger); - check(messenger); - - pn_messenger_subscribe(messenger, address); - check(messenger); - - for(;;) - { - pn_messenger_recv(messenger, 1024); - check(messenger); - - while(pn_messenger_incoming(messenger)) - { - pn_messenger_get(messenger, message); - check(messenger); - - { - char buffer[1024]; - size_t buffsize = sizeof(buffer); - const char* subject = pn_message_get_subject(message); - pn_data_t *body = pn_message_body(message); - pn_data_format(body, buffer, &buffsize); - - printf("Address: %s\n", pn_message_get_address(message)); - printf("Subject: %s\n", subject ? subject : "(no subject)"); - printf("Content: %s\n", buffer); - } - } - } - - return 0; -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/messenger/send-async.c ---------------------------------------------------------------------- diff --git a/examples/c/messenger/send-async.c b/examples/c/messenger/send-async.c deleted file mode 100644 index de9b023..0000000 --- a/examples/c/messenger/send-async.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -// This is a re-implementation of send.c using non-blocking/asynchronous calls. - -#include "proton/message.h" -#include "proton/messenger.h" - -#include "pncompat/misc_funcs.inc" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#if EMSCRIPTEN -#include <emscripten.h> -#endif - -pn_message_t * message; -pn_messenger_t * messenger; -pn_tracker_t tracker; -int running = 1; - -#define check(messenger) \ - { \ - if(pn_messenger_errno(messenger)) \ - { \ - die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \ - } \ - } \ - -void die(const char *file, int line, const char *message) -{ - fprintf(stderr, "%s:%i: %s\n", file, line, message); - exit(1); -} - -void usage(void) -{ - printf("Usage: send [-a addr] [message]\n"); - printf("-a \tThe target address [amqp[s]://domain[/name]]\n"); - printf("message\tA text string to send.\n"); - exit(0); -} - -void process(void) { - pn_status_t status = pn_messenger_status(messenger, tracker); - if (status != PN_STATUS_PENDING) { - if (running) { - pn_messenger_stop(messenger); - running = 0; - } - } - - if (pn_messenger_stopped(messenger)) { - pn_message_free(message); - pn_messenger_free(messenger); - message = NULL; - messenger = NULL; - } -} - -#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler. -void pump(int fd, void* userData) { - while (pn_messenger_work(messenger, 0) >= 0) { - process(); - } -} - -void onclose(int fd, void* userData) { - process(); -} - -void onerror(int fd, int errno, const char* msg, void* userData) { - printf("error callback fd = %d, errno = %d, msg = %s\n", fd, errno, msg); -} -#endif - -int main(int argc, char** argv) -{ - int c; - char * address = (char *) "amqp://0.0.0.0"; - char * msgtext = (char *) "Hello World!"; - pn_data_t* body; - - opterr = 0; - - while((c = getopt(argc, argv, "ha:b:c:")) != -1) - { - switch(c) - { - case 'a': address = optarg; break; - case 'h': usage(); break; - - case '?': - if(optopt == 'a') - { - fprintf(stderr, "Option -%c requires an argument.\n", optopt); - } - else if(isprint(optopt)) - { - fprintf(stderr, "Unknown option `-%c'.\n", optopt); - } - else - { - fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); - } - return 1; - default: - abort(); - } - } - - if (optind < argc) msgtext = argv[optind]; - - message = pn_message(); - messenger = pn_messenger(NULL); - pn_messenger_set_blocking(messenger, false); // Needs to be set non-blocking to behave asynchronously. - pn_messenger_set_outgoing_window(messenger, 1024); - - pn_messenger_start(messenger); - - pn_message_set_address(message, address); - body = pn_message_body(message); - pn_data_put_string(body, pn_bytes(strlen(msgtext), msgtext)); - - pn_messenger_put(messenger, message); - check(messenger); - - tracker = pn_messenger_outgoing_tracker(messenger); - -#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler. - emscripten_set_socket_error_callback(NULL, onerror); - - emscripten_set_socket_open_callback(NULL, pump); - emscripten_set_socket_connection_callback(NULL, pump); - emscripten_set_socket_message_callback(NULL, pump); - emscripten_set_socket_close_callback(NULL, onclose); -#else // For native compiler. - while (running) { - pn_messenger_work(messenger, -1); // Block indefinitely until there has been socket activity. - process(); - } - - while (messenger && !pn_messenger_stopped(messenger)) { - pn_messenger_work(messenger, 0); - process(); - } -#endif - - return 0; -} - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/examples/c/messenger/send.c ---------------------------------------------------------------------- diff --git a/examples/c/messenger/send.c b/examples/c/messenger/send.c deleted file mode 100644 index 11b47ff..0000000 --- a/examples/c/messenger/send.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "proton/message.h" -#include "proton/messenger.h" - -#include "pncompat/misc_funcs.inc" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#define check(messenger) \ - { \ - if(pn_messenger_errno(messenger)) \ - { \ - die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \ - } \ - } \ - -void die(const char *file, int line, const char *message) -{ - fprintf(stderr, "%s:%i: %s\n", file, line, message); - exit(1); -} - -void usage(void) -{ - printf("Usage: send [-a addr] [message]\n"); - printf("-a \tThe target address [amqp[s]://domain[/name]]\n"); - printf("message\tA text string to send.\n"); - exit(0); -} - -int main(int argc, char** argv) -{ - int c; - char * address = (char *) "amqp://0.0.0.0"; - char * msgtext = (char *) "Hello World!"; - opterr = 0; - - while((c = getopt(argc, argv, "ha:b:c:")) != -1) - { - switch(c) - { - case 'a': address = optarg; break; - case 'h': usage(); break; - - case '?': - if(optopt == 'a') - { - fprintf(stderr, "Option -%c requires an argument.\n", optopt); - } - else if(isprint(optopt)) - { - fprintf(stderr, "Unknown option `-%c'.\n", optopt); - } - else - { - fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); - } - return 1; - default: - abort(); - } - } - - if (optind < argc) msgtext = argv[optind]; - - { - pn_message_t * message; - pn_messenger_t * messenger; - pn_data_t * body; - - message = pn_message(); - messenger = pn_messenger(NULL); - - pn_messenger_start(messenger); - - pn_message_set_address(message, address); - body = pn_message_body(message); - pn_data_put_string(body, pn_bytes(strlen(msgtext), msgtext)); - pn_messenger_put(messenger, message); - check(messenger); - pn_messenger_send(messenger, -1); - check(messenger); - - pn_messenger_stop(messenger); - pn_messenger_free(messenger); - pn_message_free(message); - } - - return 0; -} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
