transport: empty test for sqlite converter
[abstract.git] / transport / base / aaTransportUtils.h
blob9be036a1d76933e8abca8fbbd7f59b73c0e1690c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
3 /*
4 * Copyright (C) 2010 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef AA_TRANSPORT_UTILS_H
23 #define AA_TRANSPORT_UTILS_H
25 #include "nsIPipe.h"
26 #include "nsIAsyncOutputStream.h"
27 #include "nsIAsyncInputStream.h"
29 #include "nsComponentManagerUtils.h"
31 inline nsresult
32 AA_CreatePipe(nsIInputStream **pipeIn,
33 nsIOutputStream **pipeOut,
34 PRBool nonBlockingIn = PR_TRUE)
36 nsresult rv;
38 nsCOMPtr<nsIAsyncInputStream> in;
39 nsCOMPtr<nsIAsyncOutputStream> out;
40 nsCOMPtr<nsIPipe> pipe
41 = do_CreateInstance("@mozilla.org/pipe;1", &rv);
42 NS_ENSURE_SUCCESS(rv, rv);
44 rv = pipe->Init(nonBlockingIn, PR_FALSE, 0, 0, nsnull);
45 NS_ENSURE_SUCCESS(rv, rv);
47 rv = pipe->GetInputStream(getter_AddRefs(in));
48 NS_ENSURE_SUCCESS(rv, rv);
50 rv = pipe->GetOutputStream(getter_AddRefs(out));
51 NS_ENSURE_SUCCESS(rv, rv);
53 NS_IF_ADDREF(*pipeIn = in);
54 NS_IF_ADDREF(*pipeOut = out);
55 return NS_OK;
58 #endif //AA_TRANSPORT_UTILS_H