Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
192d80e4
Commit
192d80e4
authored
Jul 25, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some files
Change-Id: I6c1cd62b19e7fc51df0a281370dd0cffa870d51d
parent
79981559
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
241 deletions
+0
-241
string_printf.cpp
json2pb/string_printf.cpp
+0
-135
string_printf.h
json2pb/string_printf.h
+0
-43
build_closure
tools/build_closure
+0
-63
No files found.
json2pb/string_printf.cpp
deleted
100644 → 0
View file @
79981559
// Copyright (c) 2011 Baidu.com, Inc. All Rights Reserved
//
// string_printf_impl, string_printf, string_appendf were taken from
// https://github.com/facebook/folly/blob/master/folly/String.cpp
// with minor changes:
// - coding style
// - replace exceptions with return code
// This file was copied from public/common in order to avoid dependency
// It should be the same content except for namespace and header guard
#include <stdio.h> // vsnprintf
#include <string.h> // strlen
#include "string_printf.h"
namespace
json2pb
{
// Copyright 2012 Facebook, Inc.
//
// Licensed 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.
namespace
{
inline
int
string_printf_impl
(
std
::
string
&
output
,
const
char
*
format
,
va_list
args
)
{
// Tru to the space at the end of output for our output buffer.
// Find out write point then inflate its size temporarily to its
// capacity; we will later shrink it to the size needed to represent
// the formatted string. If this buffer isn't large enough, we do a
// resize and try again.
const
int
write_point
=
output
.
size
();
int
remaining
=
output
.
capacity
()
-
write_point
;
output
.
resize
(
output
.
capacity
());
va_list
copied_args
;
va_copy
(
copied_args
,
args
);
int
bytes_used
=
vsnprintf
(
&
output
[
write_point
],
remaining
,
format
,
copied_args
);
va_end
(
copied_args
);
if
(
bytes_used
<
0
)
{
return
-
1
;
}
else
if
(
bytes_used
<
remaining
)
{
// There was enough room, just shrink and return.
output
.
resize
(
write_point
+
bytes_used
);
}
else
{
output
.
resize
(
write_point
+
bytes_used
+
1
);
remaining
=
bytes_used
+
1
;
bytes_used
=
vsnprintf
(
&
output
[
write_point
],
remaining
,
format
,
args
);
if
(
bytes_used
+
1
!=
remaining
)
{
return
-
1
;
}
output
.
resize
(
write_point
+
bytes_used
);
}
return
0
;
}
}
// end anonymous namespace
std
::
string
string_printf
(
const
char
*
format
,
...)
{
// snprintf will tell us how large the output buffer should be, but
// we then have to call it a second time, which is costly. By
// guestimating the final size, we avoid the double snprintf in many
// cases, resulting in a performance win. We use this constructor
// of std::string to avoid a double allocation, though it does pad
// the resulting string with nul bytes. Our guestimation is twice
// the format string size, or 32 bytes, whichever is larger. This
// is a hueristic that doesn't affect correctness but attempts to be
// reasonably fast for the most common cases.
std
::
string
ret
;
ret
.
reserve
(
std
::
max
(
32UL
,
strlen
(
format
)
*
2
));
va_list
ap
;
va_start
(
ap
,
format
);
if
(
string_printf_impl
(
ret
,
format
,
ap
)
!=
0
)
{
ret
.
clear
();
}
va_end
(
ap
);
return
ret
;
}
// Basic declarations; allow for parameters of strings and string
// pieces to be specified.
int
string_appendf
(
std
::
string
*
output
,
const
char
*
format
,
...)
{
va_list
ap
;
va_start
(
ap
,
format
);
const
size_t
old_size
=
output
->
size
();
const
int
rc
=
string_printf_impl
(
*
output
,
format
,
ap
);
if
(
rc
!=
0
)
{
output
->
resize
(
old_size
);
}
va_end
(
ap
);
return
rc
;
}
int
string_vappendf
(
std
::
string
*
output
,
const
char
*
format
,
va_list
args
)
{
const
size_t
old_size
=
output
->
size
();
const
int
rc
=
string_printf_impl
(
*
output
,
format
,
args
);
if
(
rc
==
0
)
{
return
0
;
}
output
->
resize
(
old_size
);
return
rc
;
}
int
string_printf
(
std
::
string
*
output
,
const
char
*
format
,
...)
{
va_list
ap
;
va_start
(
ap
,
format
);
output
->
clear
();
const
int
rc
=
string_printf_impl
(
*
output
,
format
,
ap
);
if
(
rc
!=
0
)
{
output
->
clear
();
}
va_end
(
ap
);
return
rc
;
};
int
string_vprintf
(
std
::
string
*
output
,
const
char
*
format
,
va_list
args
)
{
output
->
clear
();
const
int
rc
=
string_printf_impl
(
*
output
,
format
,
args
);
if
(
rc
==
0
)
{
return
0
;
}
output
->
clear
();
return
rc
;
};
}
// namespace json2pb
json2pb/string_printf.h
deleted
100644 → 0
View file @
79981559
// Copyright (c) 2011 Baidu.com, Inc. All Rights Reserved
//
// Format std::string.
//
// Author: Ge,Jun (gejun@baidu.com)
// Date: Mon. Nov 7 14:47:36 CST 2011
// This file was copied from public/common in order to avoid dependency
// It should be the same content except for namespace and header guard
#ifndef BRPC_JSON2PB_JSON_STRING_PRINTF_H
#define BRPC_JSON2PB_JSON_STRING_PRINTF_H
#include <string> // std::string
#include <stdarg.h> // va_list
namespace
json2pb
{
// Convert |format| and associated arguments to std::string
std
::
string
string_printf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
// Write |format| and associated arguments into |output|
// Returns 0 on success, -1 otherwise.
int
string_printf
(
std
::
string
*
output
,
const
char
*
fmt
,
...)
__attribute__
((
format
(
printf
,
2
,
3
)));
// Write |format| and associated arguments in form of va_list into |output|.
// Returns 0 on success, -1 otherwise.
int
string_vprintf
(
std
::
string
*
output
,
const
char
*
format
,
va_list
args
);
// Append |format| and associated arguments to |output|
// Returns 0 on success, -1 otherwise.
int
string_appendf
(
std
::
string
*
output
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
2
,
3
)));
// Append |format| and associated arguments in form of va_list to |output|.
// Returns 0 on success, -1 otherwise.
int
string_vappendf
(
std
::
string
*
output
,
const
char
*
format
,
va_list
args
);
}
// namespace json2pb
#endif // BRPC_JSON2PB_JSON_STRING_PRINTF_H
tools/build_closure
deleted
100644 → 0
View file @
79981559
#!/bin/bash
LIBS
=
"./output/lib/libbdrpc.a
\
../../lib2-64/ullib/lib/libullib.a
\
../../op/oped/noah/webfoot/naming-lib/output/libwebfoot_naming.a
\
../../public/bthread/libbthread.a
\
../../public/bvar/libbvar.a
\
../../public/common/libbase.a
\
../../public/iobuf/libiobuf.a
\
../../public/mcpack2pb/libmcpack2pb.a
\
../../public/noah/giano-lib/release/baas-lib-c/libbaas_interface.a
\
../../public/protobuf-json/libjson-pb.a
\
../../third-64/boost/lib/libboost_context.a
\
../../third-64/gflags/lib/libgflags.a
\
../../third-64/gflags/lib/libgflags_nothreads.a
\
../../third-64/gtest/lib/libgmock.a
\
../../third-64/gtest/lib/libgmock_main.a
\
../../third-64/gtest/lib/libgtest.a
\
../../third-64/gtest/lib/libgtest_main.a
\
../../third-64/libevent/lib/libevent.a
\
../../third-64/libevent/lib/libevent_core.a
\
../../third-64/libevent/lib/libevent_extra.a
\
../../third-64/libevent/lib/libevent_openssl.a
\
../../third-64/libevent/lib/libevent_pthreads.a
\
../../third-64/protobuf/lib/libprotobuf-lite.a
\
../../third-64/protobuf/lib/libprotobuf.a
\
../../third-64/protobuf/lib/libprotoc.a
\
../../third-64/tcmalloc/lib/libtcmalloc_and_profiler.a
\
../../thirdsrc/leveldb/output/lib/libleveldb.a "
INCS
=
"output/include
\
../../lib2-64/ullib/include
\
../../op/oped/noah/webfoot/naming-lib/include
\
../../public/bthread/output/include
\
../../public/bvar/output/include
\
../../public/common/output/include
\
../../public/iobuf/output/include
\
../../public/mcpack2pb/output/include
\
../../public/noah/giano-lib/release/baas-lib-c/output/include
\
../../public/protobuf-json/output/include
\
../../third-64/boost/include
\
../../third-64/gflags/include
\
../../third-64/gtest/include
\
../../third-64/protobuf/include
\
../../third-64/tcmalloc/include "
CLOSURE_DIR
=
baidu_rpc_closure
mkdir
-p
$CLOSURE_DIR
/lib
rm
-rf
`
find
$CLOSURE_DIR
-name
".svn"
-type
d
`
for
lib
in
$LIBS
;
do
cp
$lib
$CLOSURE_DIR
/lib/
done
mkdir
-p
$CLOSURE_DIR
/include
for
incdir
in
$INCS
;
do
cp
-r
$incdir
$CLOSURE_DIR
done
rm
-rf
`
find
$CLOSURE_DIR
-name
".svn"
-type
d
`
cp
-f
example/multi_threaded_echo_c++/client.cpp
$CLOSURE_DIR
/client.cpp
cp
-f
example/multi_threaded_echo_c++/server.cpp
$CLOSURE_DIR
/server.cpp
cp
-f
example/multi_threaded_echo_c++/echo.proto
$CLOSURE_DIR
/echo.proto
cp
-f
tools/build_closure.mk
$CLOSURE_DIR
/Makefile
cp
-f
../../third-64/protobuf/bin/protoc
$CLOSURE_DIR
/protoc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment