本文整理汇总了C++中check_debug函数的典型用法代码示例。如果您正苦于以下问题:C++ check_debug函数的具体用法?C++ check_debug怎么用?C++ check_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: malloc
struct Connection *Database_open(const char *filename, char mode)
{
struct Connection *conn = malloc(sizeof(struct Connection));
check_mem(conn);
check_debug(conn, "Memory error");
conn->db = malloc(sizeof(struct Database));
check_mem(conn);
check_debug(conn->db, "Memory error");
if(mode == 'c') {
conn->file = fopen(filename, "w");
} else {
conn->file = fopen(filename, "r+");
if(conn->file) {
Database_load(conn);
}
}
check_debug(conn->file, "Failed to open file");
error:
if(conn->db) free(conn->db);
if(conn->file) fclose(conn->file);
}
开发者ID:nomikomu,项目名称:yadbm,代码行数:25,代码来源:yadbm.c
示例2: dl_del
bool dl_del(list_t *list, char *new_word){
check_debug(list != NULL, "List is NULL.");
check_debug(list->prev != NULL && list->next != NULL,
"List is empty.");
check_debug(list->prev != list && list->next != list,
"List is empty.");
list_t *node = NULL;
node = list->next;
bool result = 0;
while(node != list){
list_t *next_node = node->next;
check_debug(next_node != NULL && node->prev != NULL,
"Invalid list, node: %s, node->prev: %s",
next_node == NULL ? "NULL" : "VALID",
node->prev == NULL ? "NULL" : "VALID");
if(strcmp(node->word,new_word) == 0){
check_debug(dl_remove(list, node) == 1,
"Could not delete node.");
result = 1;
}
node = next_node;
}
return result;
error:
return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:27,代码来源:dllist.c
示例3: Dir_stream_file
int Dir_stream_file(FileRecord *file, Connection *conn)
{
ssize_t sent = 0;
size_t total = 0;
off_t offset = 0;
size_t block_size = MAX_SEND_BUFFER;
// For the non-sendfile slowpath
char *file_buffer = NULL;
int nread = 0;
int amt = 0;
int tempfd = -1;
int rc = Dir_send_header(file, conn);
check_debug(rc, "Failed to write header to socket.");
if(conn->ssl == NULL) {
for(total = 0; fdwait(conn->fd, 'w') == 0 && total < file->sb.st_size;
total += sent) {
sent = Dir_send(conn->fd, file->fd, &offset, block_size);
check_debug(sent > 0, "Failed to sendfile on socket: %d from "
"file %d", conn->fd, file->fd);
}
}
else {
// We have to reopen the file, so we don't get ourselves into seek
// position trouble
int tempfd = open((const char *)(file->full_path->data), O_RDONLY);
check(tempfd >= 0, "Could not reopen open file");
file_buffer = malloc(MAX_SEND_BUFFER);
check_mem(file_buffer);
while((nread = fdread(tempfd, file_buffer, MAX_SEND_BUFFER)) > 0) {
for(amt = 0, sent = 0; sent < nread; sent += amt) {
amt = conn->send(conn, file_buffer + sent, nread - sent);
check_debug(amt > 0, "Failed to send on socket: %d from "
"file %d", conn->fd, tempfd);
}
total += nread;
}
free(file_buffer);
close(tempfd); tempfd = -1;
}
check(total <= file->sb.st_size,
"Wrote way too much, wrote %d but size was %d",
(int)total, (int)file->sb.st_size);
check(total == file->sb.st_size,
"Sent other than expected, sent: %d, but expected: %d",
(int)total, (int)file->sb.st_size);
return total;
error:
if(file_buffer) free(file_buffer);
if(tempfd >= 0) close(tempfd);
return -1;
}
开发者ID:bnoordhuis,项目名称:mongrel2,代码行数:60,代码来源:dir.c
示例4: xsd_type
/* --------------------------------------------------- */
public struct xml_element * xsd_type( struct xml_element * xsd, char * nptr )
{
struct xml_element * wptr=(struct xml_element *) 0;
struct xml_element * tptr=(struct xml_element *) 0;
struct xml_atribut * aptr;
char * vptr;
if ( check_debug() ) { printf("xsd:type( %s )\n",nptr); }
for ( wptr = document_element( xsd, _XSD_COMPLEX );
wptr != (struct xml_element *) 0;
wptr = wptr->next )
{
if ( strcasecmp( wptr->name, _XSD_COMPLEX ) )
continue;
else if (!( aptr = document_atribut( wptr, _XSD_NAME ) ))
continue;
else if (!( aptr->value ))
continue;
else if (!( vptr = occi_unquoted_value( aptr->value ) ))
continue;
else if (!( strcmp( vptr, nptr ) ))
{
liberate( vptr );
return( wptr );
}
else
{
liberate( vptr );
continue;
}
}
if ( check_debug() ) { printf("xsd:failure( attribute %s )\n",nptr); }
return( wptr );
}
开发者ID:BillTheBest,项目名称:accords-platform,代码行数:34,代码来源:cpxsd.c
示例5: connection_proxy_req_parse
int connection_proxy_req_parse(Connection *conn)
{
int rc = 0;
Host *target_host = conn->req->target_host;
Backend *req_action = conn->req->action;
check_debug(!IOBuf_closed(conn->iob), "Client closed, goodbye.");
rc = Connection_read_header(conn, conn->req);
check_debug(rc > 0, "Failed to read another header.");
error_unless(Request_is_http(conn->req), conn, 400,
"Someone tried to change the protocol on us from HTTP.");
Backend *found = Host_match_backend(target_host, Request_path(conn->req), NULL);
error_unless(found, conn, 404,
"Handler not found: %s", bdata(Request_path(conn->req)));
// break out of PROXY if the actions don't match
if(found != req_action) {
Request_set_action(conn->req, found);
return Connection_backend_event(found, conn);
} else {
return HTTP_REQ;
}
error_response(conn, 500, "Invalid code branch, tell Zed.");
error:
return REMOTE_CLOSE;
}
开发者ID:derdewey,项目名称:mongrel2,代码行数:30,代码来源:connection.c
示例6: IOBuf_stream
/**
* Streams data out of the from IOBuf and into the to IOBuf
* until it's moved total bytes between them.
*/
int IOBuf_stream(IOBuf *from, IOBuf *to, int total)
{
int need = 0;
int remain = total;
int avail = 0;
int rc = 0;
char *data = NULL;
if(from->len > to->len) IOBuf_resize(to, from->len);
while(remain > 0) {
need = remain <= from->len ? remain : from->len;
data = IOBuf_read(from, need, &avail);
check_debug(avail > 0, "Nothing in read buffer.");
rc = IOBuf_send_all(to, IOBuf_start(from), avail);
check_debug(rc == avail, "Failed to send all of the data: %d of %d", rc, avail)
// commit whatever we just did
check(IOBuf_read_commit(from, rc) != -1, "Final commit failed during streaming.");
// reduce it by the given amount
remain -= rc;
}
assert(remain == 0 && "Buffer math is wrong.");
return total - remain;
error:
return -1;
}
开发者ID:freeJim,项目名称:monserver,代码行数:37,代码来源:io.c
示例7: check
FileRecord *Dir_resolve_file(Dir *dir, bstring path)
{
FileRecord *file = NULL;
bstring target = NULL;
check(Dir_lazy_normalize_base(dir) == 0, "Failed to normalize base path when requesting %s",
bdata(path));
check(bstrncmp(path, dir->prefix, blength(dir->prefix)) == 0,
"Request for path %s does not start with %s prefix.",
bdata(path), bdata(dir->prefix));
file = FileRecord_cache_check(dir, path);
if(file) {
// TODO: double check this gives the right users count
file->users++;
return file;
}
// We subtract one from the blengths below, because dir->prefix includes
// a trailing '/'. If we skip over this in path->data, we drop the '/'
// from the URI, breaking the target path
if(bchar(path, blength(path) - 1) == '/') {
target = bformat("%s%s%s",
bdata(dir->normalized_base),
path->data + blength(dir->prefix) - 1,
bdata(dir->index_file));
} else {
target = bformat("%s%s",
bdata(dir->normalized_base),
path->data + blength(dir->prefix) - 1);
}
check(target, "Couldn't construct target path for %s", bdata(path));
check_debug(normalize_path(target) == 0, "Failed to normalize target path.");
check_debug(bstrncmp(target, dir->normalized_base, blength(dir->normalized_base)) == 0,
"Request for path %s does not start with %s base after normalizing.",
bdata(target), bdata(dir->base));
// the FileRecord now owns the target
file = Dir_find_file(target, dir->default_ctype);
check_debug(file, "Error opening file: %s", bdata(target));
// Increment the user count because we're adding it to the cache
file->users++;
file->request_path = bstrcpy(path);
Cache_add(dir->fr_cache, file);
return file;
error:
bdestroy(target);
FileRecord_release(file);
return NULL;
}
开发者ID:mattknox,项目名称:Mongrel2,代码行数:59,代码来源:dir.c
示例8: check_debug
char *dl_get_front(list_t *list){
check_debug(list != NULL, "List is NULL.");
check_debug(list->next != NULL && list->next != list,
"List is empty.");
check_debug(list->next->word != NULL,
"list->next->word is NULL.");
return list->next->word;
error:
return NULL;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:10,代码来源:dllist.c
示例9: dl_pop_back
bool dl_pop_back(list_t *list){
check_debug(list != NULL, "List is NULL.");
check_debug(list->prev != NULL && list->prev != list,
"List is empty.");
check_debug(dl_remove(list, list->prev) == 1,
"Delete from back was not successful.");
return 1;
error:
return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:10,代码来源:dllist.c
示例10: dl_pop_front
bool dl_pop_front(list_t *list){
check_debug(list != NULL, "List is NULL.");
check_debug(list->next != NULL && list->next != list,
"List is empty.");
check_debug(dl_remove(list, list->next) == 1,
"Delete from front was not successful.");
return 1;
error:
return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:10,代码来源:dllist.c
示例11: main
int main(int argc, const char *argv[])
{
fd_set allreads;
fd_set readmask;
int socket = 0;
int rc = 0;
RingBuffer *in_rb = RingBuffer_create(1024 * 10);
RingBuffer *sock_rb = RingBuffer_create(1024 * 10);
check(argc == 3, "USAGE: netclient HOST PORT");
socket = client_connect(argv[1], argv[2]);
check(socket >= 0, "Connect to %s:%s failed.", argv[1], argv[2]);
FD_ZERO(&allreads);
FD_SET(socket, &allreads);
FD_SET(0, &allreads);
while(1) {
readmask = allreads;
rc = select(socket + 1, &readmask, NULL, NULL, NULL);
check(rc >= 0, "Select failed");
if(FD_ISSET(0, &readmask)) {
rc = read_some(in_rb, 0, 0);
check_debug(rc != -1, "failed to read from stdin.");
}
if(FD_ISSET(socket, &readmask)) {
rc = read_some(sock_rb, socket, 0);
check_debug(rc != -1, "failed to read from socket.");
}
while(!RingBuffer_empty(sock_rb)) {
rc = write_some(sock_rb, 1, 0);
check_debug(rc != -1, "failed to write to stdout.");
}
while(!RingBuffer_empty(in_rb)) {
rc = write_some(in_rb, socket, 1);
check_debug(rc != -1, "failed to write to socket.");
}
}
RingBuffer_destroy(in_rb);
RingBuffer_destroy(sock_rb);
return 0;
error:
return -1;
}
开发者ID:bmoar,项目名称:c_skelly,代码行数:54,代码来源:netclient.c
示例12: Connection_deliver_enqueue
static inline int Connection_deliver_enqueue(Connection *conn, bstring b)
{
check_debug(conn->deliverPost-conn->deliverAck < DELIVER_OUTSTANDING_MSGS, "Too many outstanding messages") ;
check_debug(conn->deliverTaskStatus==DT_RUNNING, "Cannot enqueue, deliver task not running");
conn->deliverRing[conn->deliverPost++%DELIVER_OUTSTANDING_MSGS]=b;
taskwakeup(&conn->deliverRendez);
return 0;
error:
return -1;
}
开发者ID:AlexVPopov,项目名称:mongrel2,代码行数:11,代码来源:connection.c
示例13: dl_sort
bool dl_sort(list_t *list){
check_debug(list != NULL,
"list is null.");
check_debug(list->prev != NULL
&& list->next != NULL
&& list->prev != list
&& list->next != list,
"list is empty.");
while(bubble_sort(list) != 1){}
return 1;
error:
return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:13,代码来源:dllist.c
示例14: Register_fd_for_id
int Register_fd_for_id(uint32_t id)
{
RMElement *el = RadixMap_find(REG_ID_TO_FD, id);
check_debug(el != NULL, "Id %d not registered.", id);
Registration *reg = darray_get(REGISTRATIONS, el->data.value);
check_debug(Register_valid(reg), "Nothing registered under id %d.", id);
return reg->fd;
error:
return -1;
}
开发者ID:304471720,项目名称:mongrel2,代码行数:13,代码来源:register.c
示例15: dl_get_wordcount
int dl_get_wordcount(list_t *list, char *word){
check_debug(list != NULL,
"list is NULL.");
check_debug(word != NULL,
"word is NULL");
list_t *node = NULL;
node = dl_check(list, word);
check_debug(node != NULL,
"word '%s' not in list.", word);
return node->word_count;
error:
return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:13,代码来源:dllist.c
示例16: method_get_next_event
static VALUE method_get_next_event(VALUE self, VALUE blocking) {
// dbg.h
check_debug(!is_closed(self), "we are closed, not trying to get event");
char buf[64];
FETCH_DATA_PTR(self, zk);
for (;;) {
check_debug(!is_closed(self), "we're closed in the middle of method_get_next_event, bailing");
zkrb_event_t *event = zkrb_dequeue(zk->queue, 1);
/* Wait for an event using rb_thread_select() on the queue's pipe */
if (event == NULL) {
if (NIL_P(blocking) || (blocking == Qfalse)) {
goto error;
}
else {
// if we're shutting down, don't enter this section, we don't want to block
check_debug(!is_shutting_down(self), "method_get_next_event, we're shutting down, don't enter blocking section");
int fd = zk->queue->pipe_read;
ssize_t bytes_read = 0;
// wait for an fd to become readable, opposite of rb_thread_fd_writable
rb_thread_wait_fd(fd);
// clear all bytes here, we'll catch all the events on subsequent calls
// (until we run out of events)
bytes_read = read(fd, buf, sizeof(buf));
if (bytes_read == -1) {
rb_raise(rb_eRuntimeError, "read failed: %d", errno);
}
zkrb_debug_inst(self, "read %zd bytes from the queue (%p)'s pipe", bytes_read, zk->queue);
continue;
}
}
VALUE hash = zkrb_event_to_ruby(event);
zkrb_event_free(event);
return hash;
}
error:
return Qnil;
}
开发者ID:slyphon,项目名称:zookeeper-fork,代码行数:49,代码来源:zookeeper_c.c
示例17: plain_stream_file
static ssize_t plain_stream_file(IOBuf *iob, int fd, off_t len)
{
off_t sent = 0;
off_t total = 0;
off_t offset = 0;
off_t block_size = MAX_SEND_BUFFER;
int conn_fd = IOBuf_fd(iob);
for(total = 0; fdwait(conn_fd, 'w') == 0 && total < len; total += sent) {
block_size = (len - total) > block_size ? block_size : (len - total);
sent = IOBuf_sendfile(conn_fd, fd, &offset, block_size);
check(Register_write(iob->fd, sent) != -1, "Socket seems to be closed.");
check_debug(sent > 0, "Client closed probably during sendfile on socket: %d from "
"file %d", conn_fd, fd);
}
check(total <= len,
"Wrote way too much, wrote %d but size was %zd",
(int)total, len);
check(total == len,
"Sent other than expected, sent: %d, but expected: %zd",
(int)total, len);
return total;
error:
return -1;
}
开发者ID:freeJim,项目名称:monserver,代码行数:32,代码来源:io.c
示例18: AST_walk_hash
int AST_walk_hash(tst_t *settings, Value *data, ast_hash_walk_cb cb)
{
struct ASTScanData scan = {.settings = settings, .cb = cb, .error = 0};
tst_traverse(data->as.hash, ast_hash_traverse_cb, &scan);
return scan.error;
}
Value *AST_get(tst_t *settings, tst_t *fr, bstring name, ValueType type)
{
Pair *pair = tst_search(fr, bdata(name), blength(name));
check_debug(pair, "Couldn't find variable %s of type %s", bdata(name), Value_type_name(type));
Value *val = Pair_value(pair);
if(Value_is(val, REF)) {
val = Value_resolve(settings, val);
check(val, "Couldn't find variable %s of type %s",
bdata(name), Value_type_name(type));
}
check(val->type == type, "Invalid type for %s, should be %s not %s",
bdata(name), Value_type_name(type), Value_type_name(val->type));
return val;
error:
return NULL;
}
开发者ID:304471720,项目名称:mongrel2,代码行数:29,代码来源:ast.c
示例19: main
int main(int argc, char *argv[])
{
bstring url = NULL;
bstring route = NULL;
TSTree *routes = NULL;
check(argc == 2, "USAGE: urlor <urlfile>");
routes = load_routes(argv[1]);
check(routes != NULL, "Your route file has an error.");
while (1) {
url = read_line("URL> ");
check_debug(url != NULL, "goodbye.");
route = match_url(routes, url);
if (route) {
printf("MATCH: %s == %s\n", bdata(url), bdata(route));
} else {
printf("FAIL: %s\n", bdata(url));
}
bdestroy(url);
}
destroy_routes(routes);
return 0;
error:
destroy_routes(routes);
return 1;
}
开发者ID:gastlygem,项目名称:lcthw_ex,代码行数:33,代码来源:urlor.c
示例20: main
int main(int ac, char **av)
{
unsigned char board[MEM_SIZE];
t_vm *vm;
t_dlist *list;
t_dlist *list_s;
if (ac < 2)
return (0);
list = NULL;
list_s = NULL;
list = new_list(list);
list_s = new_list(list_s);
init_board(board);
vm = NULL;
vm = new_vm(vm);
fill_list(list, av);
check_debug(list, vm);
syntax(list);
find_dump(list, vm);
find_champ(list, vm, board, 0);
id_champ(vm);
champ_id_reg(vm);
init_alive(vm);
start_vm(vm, board);
winning(vm);
return (0);
}
开发者ID:agripin,项目名称:corewar,代码行数:28,代码来源:main.c
注:本文中的check_debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论