// Return -1 for error, 0 for could not open file, 1 for success. int rabin_open_file(struct sbuf *sb, struct asfd *asfd, struct cntr *cntr, struct conf **confs) { struct BFILE *bfd=&sb->protocol2->bfd; #ifdef HAVE_WIN32 if(win32_lstat(sb->path.buf, &sb->statp, &sb->winattr)) #else if(lstat(sb->path.buf, &sb->statp)) #endif { // This file is no longer available. logw(asfd, cntr, "%s has vanished\n", sb->path.buf); return 0; } sb->compression=get_int(confs[OPT_COMPRESSION]); // Encryption not yet implemented in protocol2. //sb->protocol2->encryption=conf->protocol2->encryption_password?1:0; if(attribs_encode(sb)) return -1; if(sbuf_is_metadata(sb)) return rabin_open_file_extrameta(sb, asfd, cntr); if(bfd->open_for_send(bfd, asfd, sb->path.buf, sb->winattr, get_int(confs[OPT_ATIME]), cntr, PROTO_2)) { logw(asfd, get_cntr(confs), "Could not open %s\n", sb->path.buf); return 0; } return 1; }
static int do_set_acl(struct asfd *asfd, const char *path, const char *acltext, int acltype, struct cntr *cntr) { acl_t acl; int ret=-1; if(!(acl=acl_from_text(acltext))) { logp("acl_from_text error on %s (%s): %s\n", path, acltext, strerror(errno)); logw(asfd, cntr, "acl_from_text error on %s (%s): %s\n", path, acltext, strerror(errno)); goto end; } if(acl_valid(acl)) { logp("acl_valid error on %s: %s", path, strerror(errno)); logw(asfd, cntr, "acl_valid error on %s: %s\n", path, strerror(errno)); goto end; } if(acl_set_file(path, acltype, acl)) { logp("acl set error on %s: %s", path, strerror(errno)); logw(asfd, cntr, "acl set error on %s: %s\n", path, strerror(errno)); goto end; } ret=0; end: if(acl) acl_free(acl); return ret; }
static int get_acl_string(struct asfd *asfd, acl_t acl, char **acltext, size_t *alen, const char *path, char type, struct cntr *cntr) { int ret=0; char pre[10]=""; char *tmp=NULL; ssize_t tlen=0; char *ourtext=NULL; ssize_t maxlen=0xFFFFFFFF/2; if(!(tmp=acl_to_text(acl, NULL))) { logw(asfd, cntr, "could not get ACL text of '%s'\n", path); goto end; // carry on } tlen=strlen(tmp); if(tlen>maxlen) { logw(asfd, cntr, "ACL of '%s' too long: %d\n", path, tlen); goto end; // carry on } snprintf(pre, sizeof(pre), "%c%08X", type, (unsigned int)tlen); if(!(ourtext=prepend(pre, tmp)) || !(*acltext=prepend_len(*acltext, *alen, ourtext, tlen+9, "", 0, alen))) ret=-1; end: free_w(&tmp); free_w(&ourtext); return ret; }
/* * Remove element from queue */ void queue_delete_elem(queue_t *queue, conn_t *conn) { if (queue->len <= 0) { /* queue is empty */ #ifdef LOG logw(1, "queue_delete_elem(): queue empty!"); #endif return; } if (conn->prev == NULL) { /* deleting first element */ if ((queue->beg = queue->beg->next) != NULL) queue->beg->prev = NULL; } else conn->prev->next = conn->next; if (conn->next == NULL) { /* deleting last element */ if ((queue->end = queue->end->prev) != NULL) queue->end->next = NULL; } else conn->next->prev = conn->prev; queue->len--; free((void *)conn); #ifdef DEBUG logw(5, "queue_delete_elem(): length now is %d", queue->len); #endif return; }
int open_file_for_send(BFILE *bfd, FILE **fp, const char *fname, int64_t winattr, struct cntr *cntr) { if(fp) { if(!(*fp=fopen(fname, "rb"))) { logw(cntr, "Could not open %s: %s\n", fname, strerror(errno)); return -1; } } #ifdef HAVE_WIN32 else { binit(bfd, winattr); if(bopen(bfd, fname, O_RDONLY | O_BINARY | O_NOATIME, 0, (winattr & FILE_ATTRIBUTE_DIRECTORY))<=0) { berrno be; logw(cntr, "Could not open %s: %s\n", fname, be.bstrerror(errno)); return -1; } } #endif return 0; }
bool stop() { // 1. Tell all thread to exit keepWorking = false; // 2. Wait for threads to end if ( pongInstance.videocapThreadId!= 0 ) pthread_join( pongInstance.videocapThreadId, NULL ); if ( pongInstance.redFilterThreadId!= 0 ) pthread_join( pongInstance.redFilterThreadId, NULL ); // 3. Reset thread IDs pongInstance.videocapThreadId = 0; pongInstance.redFilterThreadId = 0; //pongInstance.centroidThreadId = 0; // Release queues, so the don't live on after the application ends mq_unlink( pongInstance.mqNameVideoFull ); mq_unlink( pongInstance.mqNameVideoEmpty ); mq_unlink( pongInstance.mqNameGreenFull ); mq_unlink( pongInstance.mqNameGreenEmpty ); mq_unlink( pongInstance.mqNameRedFull ); mq_unlink( pongInstance.mqNameRedEmpty ); mq_unlink( pongInstance.mqNameXYCoords ); if(closeVideo() == 0) logw("No video device opened"); else logw("Video device closed"); log("stop completed."); return true; }
static int my_send_file(struct asfd *asfd, struct FF_PKT *ff, struct conf **confs) { static struct sbuf *sb=NULL; struct cntr *cntr=get_cntr(confs); if(!sb && !(sb=sbuf_alloc(get_protocol(confs)))) return -1; #ifdef HAVE_WIN32 if(ff->winattr & FILE_ATTRIBUTE_ENCRYPTED) { if(ff->type==FT_REG || ff->type==FT_DIR) return to_server(asfd, confs, ff, sb, CMD_EFS_FILE); return logw(asfd, cntr, "EFS type %d not yet supported: %s\n", ff->type, ff->fname); } #endif switch(ff->type) { case FT_REG: case FT_RAW: case FT_FIFO: return do_to_server(asfd, confs, ff, sb, filesymbol, in_exclude_comp(get_strlist(confs[OPT_EXCOM]), ff->fname, get_int(confs[OPT_COMPRESSION]))); case FT_DIR: case FT_REPARSE: case FT_JUNCTION: return to_server(asfd, confs, ff, sb, dirsymbol); case FT_LNK_S: return to_server(asfd, confs, ff, sb, CMD_SOFT_LINK); case FT_LNK_H: return to_server(asfd, confs, ff, sb, CMD_HARD_LINK); case FT_SPEC: return to_server(asfd, confs, ff, sb, CMD_SPECIAL); case FT_NOFSCHG: return ft_err(asfd, confs, ff, "Will not descend: " "file system change not allowed"); case FT_NOFOLLOW: return ft_err(asfd, confs, ff, "Could not follow link"); case FT_NOSTAT: return ft_err(asfd, confs, ff, "Could not stat"); case FT_NOOPEN: return ft_err(asfd, confs, ff, "Could not open directory"); default: return logw(asfd, cntr, "Err: Unknown file type %d: %s\n", ff->type, ff->fname); } }
int send_file(struct asfd *asfd, FF_PKT *ff, bool top_level, struct conf *conf) { static struct sbuf *sb=NULL; if(!sb && !(sb=sbuf_alloc(conf))) return -1; if(!file_is_included(conf, ff->fname, top_level)) return 0; #ifdef HAVE_WIN32 if(ff->winattr & FILE_ATTRIBUTE_ENCRYPTED) { if(ff->type==FT_REG || ff->type==FT_DIR) return to_server(asfd, conf, ff, sb, CMD_EFS_FILE); return logw(asfd, conf, "EFS type %d not yet supported: %s", ff->type, ff->fname); } #endif switch(ff->type) { case FT_REG: case FT_RAW: case FT_FIFO: return do_to_server(asfd, conf, ff, sb, filesymbol, in_exclude_comp(conf->excom, ff->fname, conf->compression)); case FT_DIR: case FT_REPARSE: case FT_JUNCTION: return to_server(asfd, conf, ff, sb, dirsymbol); case FT_LNK_S: return to_server(asfd, conf, ff, sb, CMD_SOFT_LINK); case FT_LNK_H: return to_server(asfd, conf, ff, sb, CMD_HARD_LINK); case FT_SPEC: return to_server(asfd, conf, ff, sb, CMD_SPECIAL); case FT_NOFSCHG: return logw(asfd, conf, "Dir: %s [will not descend: " "file system change not allowed]\n", ff->fname); case FT_NOFOLLOW: return ft_err(asfd, conf, ff, "Could not follow link"); case FT_NOSTAT: return ft_err(asfd, conf, ff, "Could not stat"); case FT_NOOPEN: return ft_err(asfd, conf, ff, "Could not open directory"); default: return logw(asfd, conf, _("Err: Unknown file type %d: %s"), ff->type, ff->fname); } }
static #endif int restore_file(struct asfd *asfd, struct bu *bu, struct sbuf *sb, enum action act, struct sdirs *sdirs, struct conf **cconfs) { int ret=-1; char *path=NULL; struct bu *b; struct bu *hlwarn=NULL; struct stat statp; struct cntr *cntr=NULL; if(cconfs) cntr=get_cntr(cconfs); // Go up the array until we find the file in the data directory. for(b=bu; b; b=b->next) { free_w(&path); if(!(path=prepend_s(b->data, sb->protocol1->datapth.buf))) goto end; if(lstat(path, &statp) || !S_ISREG(statp.st_mode)) continue; if(b!=bu && (bu->flags & BU_HARDLINKED)) hlwarn=b; if(process_data_dir_file(asfd, bu, b, path, sb, act, sdirs, cconfs)) goto end; // This warning must be done after everything else, // Because the client does not expect another cmd after // the warning. if(hlwarn) logw(asfd, cntr, "restore found %s in %s\n", iobuf_to_printable(&sb->path), hlwarn->basename); ret=0; // All OK. break; } if(!b) { logw(asfd, cntr, "restore could not find %s (%s)\n", iobuf_to_printable(&sb->path), iobuf_to_printable(&sb->protocol1->datapth)); ret=0; // Carry on to subsequent files. } end: free_w(&path); return ret; }
int zlib_inflate(struct asfd *asfd, const char *source_path, const char *dest_path, struct conf **confs) { int ret=-1; size_t b=0; uint8_t in[ZCHUNK]; struct fzp *src=NULL; struct fzp *dst=NULL; if(!(src=fzp_gzopen(source_path, "rb"))) { logw(asfd, confs, "could not gzopen %s in %s: %s\n", source_path, __func__, strerror(errno)); goto end; } if(!(dst=fzp_open(dest_path, "wb"))) { logw(asfd, confs, "could not open %s in %s: %s\n", dest_path, __func__, strerror(errno)); goto end; } while((b=fzp_read(src, in, ZCHUNK))>0) { if(fzp_write(dst, in, b)!=b) { logw(asfd, confs, "error when writing to %s\n", dest_path); goto end; } } if(!fzp_eof(src)) { logw(asfd, confs, "error while reading %s in %s\n", source_path, __func__); goto end; } if(fzp_close(&dst)) { logw(asfd, confs, "error when closing %s in %s: %s\n", dest_path, __func__, strerror(errno)); goto end; } ret=0; end: fzp_close(&src); fzp_close(&dst); return ret; }
int get_xattr(struct asfd *asfd, const char *path, char **xattrtext, size_t *xlen, struct cntr *cntr) { int ret=0; ssize_t len; int have_acl=0; char *toappend=NULL; char *xattrlist=NULL; ssize_t totallen=0; if((len=llistxattr(path, NULL, 0))<0) { logw(asfd, cntr, "could not llistxattr '%s': %zd %s\n", path, len, strerror(errno)); goto end; // Carry on. } if(!(xattrlist=(char *)calloc_w(1, len, __func__))) { ret=-1; goto end; } if((len=llistxattr(path, xattrlist, len))<0) { logw(asfd, cntr, "could not llistxattr '%s': %zd %s\n", path, len, strerror(errno)); goto end; // Carry on. } if(xattrtext && *xattrtext) { // Already have some meta text, which means that some // ACLs were set. have_acl++; } if(get_toappend(asfd, path, &toappend, xattrlist, len, &totallen, have_acl, cntr)) { ret=-1; goto end; } if(toappend) ret=append_to_extrameta(toappend, META_XATTR, xattrtext, xlen, totallen); end: free_w(&toappend); free_w(&xattrlist); return ret; }
int gv_mem_xmit (int ogf, int ocf, int opcode, int len) { int ret = 0; int enable_no_callback = 0; if (enable_no_callback && ogf == 0x3f && ocf == 0) { // LG G2 audio: hcitool cmd 3f 00 f3 88 01 02 05 logw ("NULL cback before xmit_cb()"); //opcode = 0; ret = bt_ven_cbacks->xmit_cb (opcode, gv_mem, NULL); // Send HCI command ; no callback logw ("NULL cback after xmit_cb()"); quiet_ms_sleep (20); } else ret = bt_ven_cbacks->xmit_cb (opcode, gv_mem, bfm_cback); // Send HCI command ; Callback bfm_cback() with response return (ret); }
static char *get_next_str(struct asfd *asfd, char **data, size_t *l, struct conf *conf, ssize_t *s, const char *path) { char *ret=NULL; if((sscanf(*data, "%08X", (unsigned int *)s))!=1) { logw(asfd, conf, "sscanf of xattr '%s' %d failed for %s\n", *data, *l, path); return NULL; } *data+=8; *l-=8; if(!(ret=(char *)malloc((*s)+1))) { log_out_of_memory(__func__); return NULL; } memcpy(ret, *data, *s); ret[*s]='\0'; *data+=*s; *l-=*s; return ret; }
VOID DispatchCleanup( HANDLE Handle, PEVENT_CONTEXT EventContext, PDOKAN_INSTANCE DokanInstance) { PEVENT_INFORMATION eventInfo; DOKAN_FILE_INFO fileInfo; PDOKAN_OPEN_INFO openInfo; ULONG sizeOfEventInfo = sizeof(EVENT_INFORMATION); CheckFileName(EventContext->Cleanup.FileName); eventInfo = DispatchCommon( EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo); eventInfo->Status = STATUS_SUCCESS; // return success at any case logw(L"###Cleanup %04d\n", openInfo != NULL ? openInfo->EventId : -1); if (DokanInstance->DokanOperations->Cleanup) { // ignore return value DokanInstance->DokanOperations->Cleanup( EventContext->Cleanup.FileName, &fileInfo); } openInfo->UserContext = fileInfo.Context; SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance); free(eventInfo); return; }
bool start() { // If pong already started, leave... if ( keepWorking ) { logw("Called start twice. Stop pong first."); return false; } keepWorking = true; // Reset all thread identifiers pongInstance.videocapThreadId = 0; pongInstance.redFilterThreadId = 0; //pongInstance.centroidThreadId = 0; // Launch all treads if ( !startVideocap() ) return false; if ( !startRedFilter() ) return false; //if ( !startCentroid() ) return false; log("start completed."); return true; }
int restore_sbuf_protocol1(struct asfd *asfd, struct sbuf *sb, struct bu *bu, enum action act, struct sdirs *sdirs, enum cntr_status cntr_status, struct conf **cconfs) { if((sb->protocol1->datapth.buf && asfd->write(asfd, &(sb->protocol1->datapth))) || asfd->write(asfd, &sb->attr)) return -1; else if(sbuf_is_filedata(sb) || sbuf_is_vssdata(sb)) { if(!sb->protocol1->datapth.buf) { logw(asfd, get_cntr(cconfs), "Got filedata entry with no datapth: %c:%s\n", sb->path.cmd, sb->path.buf); return 0; } return restore_file(asfd, bu, sb, act, sdirs, cconfs); } else { if(asfd->write(asfd, &sb->path)) return -1; // If it is a link, send what // it points to. else if(sbuf_is_link(sb) && asfd->write(asfd, &sb->link)) return -1; cntr_add(get_cntr(cconfs), sb->path.cmd, 0); } return 0; }
VOID PrintAvailableMemory() { WCHAR sz[MAX_PATH] = { 0 }; _i64tow_s(GetAvailableMemory(), sz, _countof(sz), 10); std::wstring s = AddComma(sz); logw(L"AvailableMemory: %s", s.c_str()); }
int RequestVideoStreamBuffer(VideoDecoder* pDecoder, int nRequireSize, char** ppBuf, int* pBufSize, char** ppRingBuf, int* pRingBufSize, int nStreamBufIndex) { char* pStart; char* pStreamBufEnd; char* pMem; int nFreeSize; Sbm* pSbm; VideoDecoderContext* p; logi("RequestVideoStreamBuffer, pDecoder=%p, nRequireSize=%d, nStreamBufIndex=%d", pDecoder, nRequireSize, nStreamBufIndex); p = (VideoDecoderContext*)pDecoder; *ppBuf = NULL; *ppRingBuf = NULL; *pBufSize = 0; *pRingBufSize = 0; pSbm = p->pSbm; if(pSbm == NULL) { logw("pSbm of video stream %d is NULL, RequestVideoStreamBuffer fail.", nStreamBufIndex); return -1; } //* sometimes AVI parser will pass empty stream frame to help pts calculation. //* in this case give four bytes even the parser does not need. if(nRequireSize == 0) nRequireSize = 4; //* we've filled partial frame data but not added to the SBM before, //* we need to calculate the actual buffer pointer by self. nRequireSize += p->partialStreamDataInfo.nLength; if(SbmRequestBuffer(pSbm, nRequireSize, &pMem, &nFreeSize) < 0) { logi("request stream buffer fail, %d bytes valid data in SBM[%d], total buffer size is %d bytes.", SbmStreamDataSize(pSbm), nStreamBufIndex, SbmBufferSize(pSbm)); return -1; } //* check the free buffer is larger than the partial data we filled before. if(nFreeSize <= p->partialStreamDataInfo.nLength) { logi("require stream buffer get %d bytes, but this buffer has been filled with partial \ frame data of %d bytes before, nStreamBufIndex=%d.", nFreeSize, p->partialStreamDataInfo.nLength, nStreamBufIndex); return -1; }
static #endif char *get_next_xattr_str(struct asfd *asfd, char **data, size_t *l, struct cntr *cntr, ssize_t *s, const char *path) { char *ret=NULL; if((sscanf(*data, "%08X", (unsigned int *)s))!=1) { logw(asfd, cntr, "sscanf of xattr '%s' %zd failed for %s\n", *data, *l, path); return NULL; } *data+=8; *l-=8; if(!(ret=(char *)malloc_w((*s)+1, __func__))) return NULL; memcpy(ret, *data, *s); ret[*s]='\0'; *data+=*s; *l-=*s; return ret; }
static int close_db(const char *name, FILE *db, FILE *udb, bool updated) { fclose(db); if (udb) { char upath[PATH_MAX]; fclose(udb); dbup(name, upath, sizeof(upath)); if (updated) { char path[PATH_MAX]; dbp(name, path, sizeof(path)); if (rename(upath, path)) { loge("Can't update database: %m\n"); return -1; } } else { if (unlink(upath)) logw("Can't remove update database: %m\n"); } } return 0; }
int zlib_inflate(struct asfd *asfd, const char *source, const char *dest, struct conf *conf) { int ret=-1; size_t b=0; FILE *fp=NULL; gzFile zp=NULL; unsigned char in[ZCHUNK]; if(!(zp=gzopen_file(source, "rb"))) { logw(asfd, conf, "could not open %s in %s\n", source, __func__); goto end; } if(!(fp=open_file(dest, "wb"))) { logw(asfd, conf, "could not open %s in %s: %s\n", dest, __func__, strerror(errno)); goto end; } while((b=gzread(zp, in, ZCHUNK))>0) { if(fwrite(in, 1, b, fp)!=b) { logw(asfd, conf, "error when writing to %s\n", dest); goto end; } } if(!gzeof(zp)) { logw(asfd, conf, "error while gzreading %s in %s\n", source, __func__); goto end; } if(close_fp(&fp)) { logw(asfd, conf, "error when closing %s in %s: %s\n", dest, __func__, strerror(errno)); goto end; } ret=0; end: gzclose_fp(&zp); close_fp(&fp); return ret; }
struct iovec *rpc_recv_buf(struct rpc *r) { struct iovec *buf = CALLOC(1, struct iobuf); struct rpc_packet *recv_pkt = &r->recv_pkt; uint32_t uuid_dst; uint32_t uuid_src; int ret; int head_size = sizeof(rpc_header_t); ret = skt_recv(r->fd, (void *)&recv_pkt->header, head_size); if (ret == 0) { //loge("peer connect closed\n"); goto err; } else if (ret != head_size) { loge("skt_recv failed, head_size = %d, ret = %d\n", head_size, ret); goto err; } uuid_src = r->recv_pkt.header.uuid_src; uuid_dst = r->send_pkt.header.uuid_src; if (uuid_src != 0 && uuid_dst != 0 && uuid_src != uuid_dst) { logw("uuid_src(0x%08x) is diff from received uuid_dst(0x%08x)\n", uuid_src, uuid_dst); logw("this maybe a peer call\n"); } else { //loge("uuid match.\n"); } buf->iov_len = recv_pkt->header.payload_len; buf->iov_base = calloc(1, buf->iov_len); recv_pkt->payload = buf->iov_base; ret = skt_recv(r->fd, buf->iov_base, buf->iov_len); if (ret == 0) { loge("peer connect closed\n"); goto err; } else if (ret != buf->iov_len) { loge("skt_recv failed: rlen=%d, ret=%d\n", buf->iov_len, ret); goto err; } return buf; err: if (buf->iov_base) { free(buf->iov_base); } free(buf); return NULL; }
int HUServer::hu_handle_AudioFocusRequest (int chan, byte * buf, int len) { // Navigation Focus Request HU::AudioFocusRequest request; if (!request.ParseFromArray(buf, len)) loge ("AudioFocusRequest Focus Request"); else logw ("AudioFocusRequest Focus Request %s: %d", chan_get(chan), request.focus_type()); callbacks.AudioFocusRequest(chan, request); return 0; }
static int size_checks(struct asfd *asfd, struct sbuf *sb, struct conf *conf) { if(sb->path.cmd!=CMD_FILE && sb->path.cmd!=CMD_ENC_FILE && sb->path.cmd!=CMD_EFS_FILE) return 0; if(conf->min_file_size && sb->statp.st_size<(boffset_t)conf->min_file_size) { logw(asfd, conf, "File size decreased below min_file_size after initial scan: %c:%s", sb->path.cmd, sb->path.buf); return -1; } if(conf->max_file_size && sb->statp.st_size>(boffset_t)conf->max_file_size) { logw(asfd, conf, "File size increased above max_file_size after initial scan: %c:%s", sb->path.cmd, sb->path.buf); return -1; } return 0; }
int HUServer::hu_aap_start (HU_TRANSPORT_TYPE transportType, bool waitForDevice) { // Starts Transport/USBACC/OAP, then AA protocol w/ VersReq(1), SSL handshake, Auth Complete if (iaap_state == hu_STATE_STARTED || iaap_state == hu_STATE_STARTIN) { loge ("CHECK: iaap_state: %d (%s)", iaap_state, state_get (iaap_state)); return (0); } pthread_setname_np(pthread_self(), "main_thread"); iaap_state = hu_STATE_STARTIN; logd (" SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state)); int ret = ihu_tra_start (transportType, waitForDevice); // Start Transport/USBACC/OAP if (ret) { iaap_state = hu_STATE_STOPPED; logd (" SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state)); return (ret); // Done if error } byte vr_buf [] = { 0, 1, 0, 1}; // Version Request ret = hu_aap_unenc_send_blob(0, AA_CH_CTR, HU_INIT_MESSAGE::VersionRequest, vr_buf, sizeof (vr_buf), 2000); if (ret < 0) { loge ("Version request send ret: %d", ret); return (-1); } while(iaap_state == hu_STATE_STARTIN) { ret = hu_aap_recv_process(2000); if (ret < 0) { hu_aap_shutdown(); return (ret); } } int pipefd[2]; ret = pipe2(pipefd, O_DIRECT); if (ret < 0) { loge ("pipe2 failed ret: %d %i", ret, errno); hu_aap_shutdown (); return (-1); } logw("Starting HU thread"); command_read_fd = pipefd[0]; command_write_fd = pipefd[1]; hu_thread_quit_flag = false; hu_thread = std::thread([this] { this->hu_thread_main(); }); return (0); }
/* * Set connection CONN to STATE */ void state_conn_set(conn_t *conn, int state) { switch (state) { case CONN_HEADER: conn->ctr = 0; #ifdef DEBUG logw(5, "conn[%s]: state now is CONN_HEADER", inet_ntoa(conn->sockaddr.sin_addr)); #endif break; #ifdef DEBUG case CONN_RQST: logw(5, "conn[%s]: state now is CONN_RQST", inet_ntoa(conn->sockaddr.sin_addr)); break; case CONN_TTY: logw(5, "conn[%s]: state now is CONN_TTY", inet_ntoa(conn->sockaddr.sin_addr)); break; #endif case CONN_RESP: conn->ctr = 0; #ifdef DEBUG logw(5, "conn[%s]: state now is CONN_RESP", inet_ntoa(conn->sockaddr.sin_addr)); #endif break; default: /* unknown state, exiting */ #ifdef DEBUG logw(5, "conn_set_state([%s]) - invalid state (%d)", inet_ntoa(conn->sockaddr.sin_addr), state); #endif exit (-1); } conn->state = state; /* reset timeout value */ conn->timeout = cfg.conntimeout; }
void test_file_name() { int i; for (i = 0; i < 1; i++) { loge("debug msg i=%d\n", i); logw("debug msg i=%d\n", i); logi("debug msg i=%d\n", i); logd("debug msg i=%d\n", i); logv("debug msg i=%d\n", i); } log_deinit(); }
static int ft_err(struct asfd *asfd, struct conf **confs, struct FF_PKT *ff, const char *msg) { int raise_error; const char *prefix=""; raise_error=get_int(confs[OPT_SCAN_PROBLEM_RAISES_ERROR]); if(raise_error) prefix="Err: "; if(logw(asfd, get_cntr(confs), "%s%s %s: %s\n", prefix, msg, ff->fname, strerror(errno))) return -1; if(raise_error) return -1; return 0; }
///* int bc_g2_pcm_set () { unsigned char res_buf [MAX_HCI]; int res_len; logw ("bc_g2_pcm_set 1"); // hcitool cmd 3f 00 f3 88 01 02 05 unsigned char hci_g2 [] = {0, 0, 0, 0, 0x01, 0x00, 0xfc, 0x05, 0xf3, 0x88, 0x01, 0x02, 0x05 }; // OGF: 0x3f OCF: 0x00 Parameter Total Length: 5 int hci_len = sizeof (hci_g2) - 8; // 13 - 8 = 5 void * res_ptr = bfm_send (& hci_g2 [5], hci_len + 3); // 5 + 3 = 8 //unsigned char hci_buf [] = {0, 0, 0, 0, 0, 0, 0, 0, 0xf3, 0x88, 0x01, 0x02, 0x05}; //hci_buf [5] = 0; // ocf //hci_buf [6] = 0xfc; // ogf << 2 //hci_buf [7] = 5; // ? //void * res_ptr = bfm_send (& hci_buf [5], sizeof (hci_buf) - 5); if (res_ptr == NULL) loge ("bc_g2_pcm_set bfm_send error res_ptr: %p", res_ptr); else logw ("bc_g2_pcm_set OK"); return (0); }
int HUServer::hu_handle_VideoFocusRequest(int chan, byte * buf, int len) { HU::VideoFocusRequest request; if (!request.ParseFromArray(buf, len)) loge ("VideoFocusRequest"); else logw ("VideoFocusRequest: %d", request.disp_index()); callbacks.VideoFocusRequest(chan, request); return 0; }