/* * rw_dungeon * セーブデータからのダンジョン情報の保存と復元 */ void rw_dungeon(FILE *fp, boolean rw) { short i, j; char buf[ROGUE_COLUMNS]; if (rw) { // 書き込み時実行 for (i = 0; i < ROGUE_LINES; i++) { r_write(fp, (char *) dungeon[i], (ROGUE_COLUMNS * sizeof(dungeon[0][0]))); for (j = 0; j < ROGUE_COLUMNS; j++) { buf[j] = mvinch_rogue(i, j); } r_write(fp, buf, ROGUE_COLUMNS); } return; } else { // 読み込み時実行 for (i = 0; i < ROGUE_LINES; i++) { r_read(fp, (char *) dungeon[i], (ROGUE_COLUMNS * sizeof(dungeon[0][0]))); r_read(fp, buf, ROGUE_COLUMNS); if ( i < ROGUE_LINES - 1 ) { for (j = 0; j < ROGUE_COLUMNS; j++) { mvaddch_rogue(i, j, (unsigned char) buf[j]); } } else { print_stats(STAT_ALL); } } return; } }
int main(int argc, char *argv[]) { int i; char reqbuf[1]; int reqfd, seqfd; long seqnum; if (argc != 3) { fprintf(stderr, "Usage: %s requestfifo sequencefifo\n", argv[0]); return 1; } if ((reqfd = open(argv[REQUEST_FIFO], O_WRONLY)) == -1 || ((seqfd = open(argv[SEQUENCE_FIFO], O_RDONLY)) == -1)) { perror("Client failed to open a FIFO"); return 1; } for (i = 0; i < REPEAT_MAX; i++) { reqbuf[0] = OK_CHAR; sleep((int) (SLEEP_MAX * drand48())); if (r_write(reqfd, reqbuf, 1) == -1) { perror("Client failed to write request"); break; } if (r_read(seqfd, &seqnum, sizeof(seqnum)) != sizeof(seqnum)) { fprintf(stderr, "Client failed to read full sequence number\n"); reqbuf[0] = ERROR_CHAR; r_write(reqfd, reqbuf, 1); break; } fprintf(stderr, "[%ld]:received sequence number %ld\n", (long) getpid(), seqnum); } return 0; }
int main(int argc, char *argv[]) { char buf[BUFSIZE]; ssize_t bytesread; char hostinfo[BUFSIZE]; int mcastfd; u_buf_t mcastinfo; u_port_t mcastport; u_buf_t senderinfo; if (argc != 3) { fprintf(stderr, "Usage: %s multicast-address multicast-port\n", argv[0]); return 1; } mcastport = (u_port_t)atoi(argv[2]); /* join the multicast group */ if ((mcastfd = u_join(argv[1], mcastport, &mcastinfo)) == -1) { perror("Failed to join multicast group"); return 1; } u_gethostinfo(&mcastinfo, buf, BUFSIZE); fprintf(stderr, "Info: %s\n", buf); fprintf(stderr, "mcastfd is %d\n", mcastfd); /* read information from multicast, send to standard output */ while ((bytesread = u_recvfrom(mcastfd, buf, BUFSIZE, &senderinfo)) > 0) { u_gethostinfo(&senderinfo, hostinfo, BUFSIZE); if ((r_write(STDOUT_FILENO, hostinfo, strlen(hostinfo)) == -1) || (r_write(STDOUT_FILENO, buf, bytesread) == -1)) { perror("Failed to echo message received to standard output"); break; } } return 0; }
void RF_destroy(RF_class *RF, WORD compact_threshold) { OD_link *link, *next; WORD lost_percent; ULONG lost_space, entry, nentries; RF_class *new_class, *old; BYTE *RF_filename, *temp_fn; if (RF->touched) { lseek(RF->file, 0L, SEEK_SET); r_write(RF->file, &RF->hdr, sizeof(RF_file_hdr)); } link = RF->root; while (link != NULL) { if (link->touched) { lseek(RF->file, link->origin, SEEK_SET); r_write(RF->file, &link->blk, sizeof(OD_block)); } next = link->next; mem_free(link); link = next; } close(RF->file); lost_space = RF->hdr.lost_space; lost_percent = (WORD) ((lost_space * 100L) / RF->hdr.file_size); RF_filename = str_alloc(RF->filename); mem_free(RF->filename); mem_free(RF); if (lost_space && (lost_percent >= compact_threshold)) { rename(RF_filename, temp_fn = temp_filename(NULL)); old = RF_construct(temp_fn, 0); new_class = RF_construct(RF_filename, 1); new_class->hdr.modify_time = old->hdr.modify_time; new_class->hdr.create_time = old->hdr.create_time; new_class->touched = 1; nentries = RF_entry_count(old); for (entry = 0; entry < nentries; entry++) { RF_new_entry(new_class, &old->file, RF_header(old, entry), RTYP_HOUSECLEAN); RF_set_flags(new_class, entry, RF_flags(old, entry)); } RF_destroy(new_class, 0); RF_destroy(old, 100); remove_tempfile(temp_fn); } mem_free(RF_filename); }
void write_string(char *s, FILE *fp) { short n; n = strlen(s) + 1; xxxx(s, n); r_write(fp, (char *) &n, sizeof(short)); r_write(fp, s, n); }
void write_pack(object *pack, FILE *fp) { object t; while ((pack = pack->next_object)) { r_write(fp, (char *) pack, sizeof(object)); } t.ichar = t.what_is = 0; r_write(fp, (char *) &t, sizeof(object)); }
int main (int argc, char *argv[]) { time_t curtime; int len; char requestbuf[PIPE_BUF]; int requestfd; if (argc != 2) { /* name of server fifo is passed on the command line */ fprintf(stderr, "Usage: %s fifoname\n", argv[0]); return 1; } if ((requestfd = open(argv[FIFOARG], O_WRONLY)) == -1) { perror("Client failed to open log fifo for writing"); return 1; } curtime = time(NULL); snprintf(requestbuf, PIPE_BUF, "%d: %s", (int)getpid(), ctime(&curtime)); len = strlen(requestbuf); if (r_write(requestfd, requestbuf, len) != len) { perror("Client failed to write"); return 1; } r_close(requestfd); return 0; }
void RF_delete_entry(RF_class *RF, ULONG entry) { RF_entry_hdr RHDR; ULONG blknum; UWORD i; OD_link *link; blknum = (entry / (ULONG) OD_SIZE); // blknum = directory block # i = (UWORD) (entry % (ULONG) OD_SIZE); // i = entry # within block link = RF->root; while (blknum--) { link = link->next; if (link == NULL) return; } if (link->blk.flags[i] & (SA_UNUSED | SA_DELETED)) return; lseek(RF->file, link->blk.index[i], SEEK_SET); r_read(RF->file, &RHDR, sizeof(RF_entry_hdr)); link->blk.flags[i] |= SA_DELETED; link->touched = 1; RF->hdr.lost_space += RHDR.data_size; RF->touched = 1; RHDR.data_size = 0L; lseek(RF->file, link->blk.index[i], SEEK_SET); r_write(RF->file, &RHDR, sizeof(RF_entry_hdr)); }
/* Fork a chain of processes */ int main(int argc, char *argv[]) { char buf[] = "g"; pid_t child = 0; int fd[2]; int i, n; if (argc != 2) { fprintf(stderr, "Usage: %s processes\n", argv[0]); return 1; } n = atoi(argv[1]); if (pipe(fd) == -1) { /* create pipe */ perror("Failed to create pipe"); return 1; } for (i = 0; i < n; i++) /* create fan of processes */ if ((child = fork()) <= 0) break; if (child > 0) { /* write synchronization chars to pipe */ for (i = 0; i < n; i++) if (r_write(fd[1], buf, 1) != 1) perror("Failed to write sync characters"); } if (r_read(fd[0], buf, 1) != 1) /* synchronize here */ perror("Failed to read sync characters"); fprintf(stderr, "i:%d process ID:%ld parent ID:%ld child ID:%ld\n", i, (long)getpid(), (long)getppid(), (long)child); return 0; }
ULONG RF_new_entry(RF_class *RF, void *source, RF_entry_hdr *RHDR, UWORD type) { ULONG entry; WORD i, j, found; OD_link *link, *newlink, *next; found = 0; entry = 0L; // set entry = index of next available entry next = RF->root; // link = pointer to block in chain do // i = entry within block { link = next; for (i = 0; i < OD_SIZE; i++) { j = link->blk.flags[i]; if (j & SA_UNUSED) { found = 1; break; } if ((j & SA_DELETED) && (type != RTYP_HOUSECLEAN)) return (RF_write_entry(RF, entry, source, RHDR, type)); entry++; } next = link->next; } while ((next != NULL) && (!found)); if (!found) // at end of directory; must create new link { newlink = (OD_link*) mem_alloc(sizeof(OD_link)); link->next = newlink; link->blk.next = RF->hdr.file_size; link->touched = 1; newlink->next = NULL; newlink->blk.next = 0L; for (i = 0; i < OD_SIZE; i++) { newlink->blk.flags[i] = SA_UNUSED; newlink->blk.index[i] = 0; } newlink->origin = lseek(RF->file, 0L, SEEK_END); r_write(RF->file, &newlink->blk, sizeof(OD_block)); RF->hdr.file_size += sizeof(OD_block); RF->touched = 1; link = newlink; i = 0; } link->blk.index[i] = RF->hdr.file_size; link->blk.flags[i] &= (~SA_UNUSED); link->touched = 1; return (RF_write_entry(RF, entry, source, RHDR, type)); }
int readwriteblock(int fromfd, int tofd, char *buf, int size) { int bytesread; bytesread = readblock(fromfd, buf, size); if (bytesread != size) /* can only be 0 or -1 */ return bytesread; return r_write(tofd, buf, size); }
int main(int argc, char *argv[]) { char buf[BUFSIZE]; char host_info[BUFSIZE]; int mcastfd; u_buf_t mcast_info; u_port_t mcastport; ssize_t nbytes_read; u_buf_t sender_info; int count; if (argc != 3) { fprintf(stderr, "Usage: %s Multicast-Address Multicast-Port\n", argv[0]); return 1; } /* join the multicast group */ mcastport = (u_port_t)atoi(argv[2]); if ((mcastfd = u_join(argv[1], mcastport, &mcast_info)) == -1) { perror("Receiver failed to join multicast group"); return 1; } u_gethostinfo(&mcast_info,buf,BUFSIZE); fprintf(stderr,"Info: %s\n",buf); fprintf(stderr,"mcastfd is %d\n",mcastfd); /* multicast information read from standard input */ count = 0; while ((nbytes_read = u_recvfrom(mcastfd, buf, BUFSIZE, &sender_info)) > 0) { u_gethostinfo(&sender_info, host_info, BUFSIZE); if ((r_write(STDOUT_FILENO, host_info, strlen(host_info)) == -1) || (r_write(STDOUT_FILENO, buf, nbytes_read) == -1)) { perror("Error echoing sender or message to standard output"); break; } count++; if (count == 5) { fprintf(stderr,"Leaving group\n"); if (u_leave(mcastfd,&mcast_info) == -1) perror("Error leaving group"); } } return 0; }
void shell::stopLocatorThread(){ r_write(processToLocatorThreadPipe[1], (void*)"exit", MAXBUFFER); pthread_join( *locatorThreadHandle, NULL); if(close(processToLocatorThreadPipe[0])||close(processToLocatorThreadPipe[1])) perror("Failed to close p2L pipe"); if(close(locatorThreadToProcessPipe[0])||close(locatorThreadToProcessPipe[1])) perror("Failed to close l2P pipe"); sem_destroy(locatorAccessSemaphore); }
void rw_id(struct id id_table[], FILE *fp, int n, boolean wr) { short i; for (i = 0; i < n; i++) { if (wr) { r_write(fp, (char *) &(id_table[i].value), sizeof(short)); r_write(fp, (char *) &(id_table[i].id_status), sizeof(unsigned short)); write_string(id_table[i].title, fp); } else { r_read(fp, (char *) &(id_table[i].value), sizeof(short)); r_read(fp, (char *) &(id_table[i].id_status), sizeof(unsigned short)); read_string(id_table[i].title, fp); } } }
void rw_rooms(FILE *fp, boolean rw) { short i; for (i = 0; i < MAXROOMS; i++) { rw ? r_write(fp, (char *) (rooms + i), sizeof(room)) : r_read(fp, (char *) (rooms + i), sizeof(room)); } }
/** * reads at most PIPE_BUF bytes from open file descriptor fromfd and writes the * bytes read to the open file descriptor tofd. If successful, r_readwrite returns the * number of bytes copied. If r_readwrite reaches end-of-file on fromfd, it returns * 0. If unsuccessful, r_readwrite returns –1 and sets errno. */ int r_readwrite(int fromfd, int tofd) { char buf[BLKSIZE]; int bytesread; if ((bytesread = r_read(fromfd, buf, BLKSIZE)) < 0) return -1; if (bytesread == 0) return 0;if (r_write(tofd, buf, bytesread) < 0) return -1; return bytesread; }
/* * rend_send_message * * Send a rendezvous message */ int rend_send_message(REND_MESSAGE *pmsg) { int retval; if(r_write(rend_pipe_to[WR_SIDE],pmsg,sizeof(REND_MESSAGE)) == -1) return -1; if((retval=r_read(rend_pipe_from[RD_SIDE],&retval,sizeof(int)) == -1)) return -1; return retval; }
/* Send the local time with each logged message. * Return 0 on success and -1 on failure. */ int lsendtime(LFILE *mf) { if (mf == NULL) return -1; mf->tmode = 1; if (r_write(mf->fd, "-", 1) < 0) { if (ldebug_flag) fprintf(stderr, "Pipe write error\n"); return -1; } return 0; }
static bool_t xdr_std_msg_send(xdr_s_type *xdr) { int ret; /* Send the RPC packet. */ ret = r_write(xdr->fd, (void *)xdr->out_msg, xdr->out_next); xdr->xdr_err = ret; if ( ret != xdr->out_next) return FALSE; return TRUE; }
/* This function is used to execute in a thread. It will connect a server with hostname and port number. It will send a full path of the named filename under the current working directory to the server. The server will return back a point to a number, if successful is 0, failed is 1. The mutex lock is used to lock the communication process. */ void *threadconnect(void *arg) { char flag[1]; int flag_num; int bytescopied; int communfd; int error; char compilepath[BLKSIZE]; int i =0; const char *str_name; struct connectpara *cp; cp = (struct connectpara *)(arg); u_port_t pn = 0; char *hn = NULL; char *fn = NULL; pn = (*cp).portnumber; hn = (*cp).hostname; fn = (*cp).filename; if ((communfd = u_connect(pn, hn)) == -1) { perror("Failed to establish connection"); return NULL; } fprintf(stderr, "[%ld]:connection made to %s\n", (long)getpid(), hn); str_name = fn; getcwd(compilepath, BLKSIZE); strcat(compilepath, "/"); strcat(compilepath, str_name); strcat(compilepath, "\n"); if(r_write(communfd, compilepath, strlen(compilepath)) < 0) { fprintf(stderr, "Could not write to communfd\n"); return NULL; } if ((i = r_read(communfd, flag, 1)) < 0) { //read flag from STDOUT_FILENO fprintf(stderr, "Could not read flag from communfd.\n"); return NULL; } if(flag_num = (int) atoi(flag)) { return &one; } else { return &zero; } }
int copyfile(int fromfd, int tofd) { char buf[BLKSIZE]; int bytesread, byteswritten; int totalbytes = 0; for ( ; ; ) { if ((bytesread = r_read(fromfd, buf, BLKSIZE)) <= 0) break; if ((byteswritten = r_write(tofd, buf, bytesread)) == -1) break; totalbytes += byteswritten; } return totalbytes; }
char *shell::passToLocator(const char*command){ //fprintf(stderr,"passToLocator\n"); int bytesSent, bytesRead=-1, myError; char buffer[MAXBUFFER]; char *newCommand; sem_wait(locatorAccessSemaphore); //I need you tonight. //fprintf(stderr,"Access Semaphore received.\n"); bytesSent=r_write(processToLocatorThreadPipe[1], (void*)command, (std::strlen(command)+1)); bytesRead=r_read(locatorThreadToProcessPipe[0], (void*)buffer, MAXBUFFER); //fprintf(stderr,"Bytes read: %d!\n", bytesRead); sem_post(locatorAccessSemaphore); //Let's go our separate ways. //fprintf(stderr,"Access Semaphore returned.\n"); newCommand=new char[std::strlen(buffer)+1]; std::strcpy(newCommand,buffer); return newCommand; }
int putblock(char *fname, int blknum, char *data) { int error = 0; int file; if ((file = open(fname, O_WRONLY|O_CREAT, PUTBLOCK_PERMS)) == -1) return -1; if (lseek(file, blknum*BLKSIZE, SEEK_SET) == -1) error = errno; else if (r_write(file, data, BLKSIZE) == -1) error = errno; if ((r_close(file) == -1) && !error) error = errno; if (!error) return 0; errno = error; return -1; }
/* Read from infd and write to outfd until an error or end-of-file occurs */ static void readwriteall(int infd, int outfd) { char buf[RWBUFSIZE]; int bytes_read; while ((bytes_read = r_read(infd, buf, RWBUFSIZE)) > 0) { if (r_write(outfd, buf, bytes_read) != bytes_read) { if (ldebug_flag) fprintf(stderr, "Pipe write error\n"); close(infd); close(outfd); return; } } if (bytes_read < 0) { if (ldebug_flag) fprintf(stderr, "Pipe read error\n"); } close(infd); close(outfd); }
void *shell::locatorThread(void *arguments){ int bytesRead,bytesSent=-1, myError; char buffer[MAXBUFFER]; std::string fullCommandName; while(running){ bytesRead=r_read(processToLocatorThreadPipe[0], buffer, MAXBUFFER); //fprintf(stderr,"Bytes read: %d!\n", bytesRead); //fprintf(stderr,"Buffer contents: %s\n", buffer); buffer[bytesRead-1]=0; //Cap it with a null, just to make sure fullCommandName=locatorFindFile(buffer); //bytesRead=r_write(locatorThreadToProcessPipe[0], (void*)fullCommandName.c_str(), (fullCommandName.size()+1)); //fprintf(stderr,"File Location: %s\n", fullCommandName.c_str()); std::strcpy(buffer, fullCommandName.c_str()); //fprintf(stderr,"Buffer contents: %s\n", buffer); bytesSent=r_write(locatorThreadToProcessPipe[1], buffer, std::strlen(buffer)+1); //fprintf(stderr,"Bytes Sent: %d\n", bytesSent); fullCommandName.clear(); } return NULL; }
int main(int argc, char *argv[]) { time_t curtime; int len; char buf[PIPE_BUF]; int fd; if (argc != 2) err_quit("Usage: %s filename", argv[0]); if ((fd = open(argv[1], O_WRONLY)) == -1) err_sys("client: open logfile failed: %s", argv[1]); curtime = time(NULL); snprintf(buf, PIPE_BUF, "%d: %s", (int)getpid(), ctime(&curtime)); len = strlen(buf); if (r_write(fd, buf, len) != len) err_sys("client: failed to write"); r_close(fd); return 0; }
int main(int argc, char *argv[]) { ssize_t bytesread, byteswritten; char request[BUFSIZE]; int requestfd; char reply[BUFSIZE]; u_port_t serverport; double timeout; int retries; if (argc != 5) { fprintf(stderr, "Usage: %s servername serverport timeout retries\n", argv[0]); return 1; } serverport = (u_port_t) atoi(argv[2]); timeout = atof(argv[3]); retries = atof(argv[4]); if ((requestfd = u_openudp(0)) == -1) { /* create an unbound UDP endpoint */ perror("UDP endpoint creation failed"); return 1; } sprintf(request, "[%ld]\n", (long)getpid()); /* create request string */ /* use request-reply protocol with timeout to send a message */ bytesread = request_reply_timeout_retry(requestfd, request, strlen(request) + 1, argv[1], serverport, reply, BUFSIZE, timeout, retries); if (bytesread < 0) perror("Failed to complete request_reply_timeout_retry"); else { byteswritten = r_write(STDOUT_FILENO, reply, bytesread); if (byteswritten < 0) perror("Failed to echo server reply"); } if (r_close(requestfd) == -1 || bytesread < 0 || byteswritten < 0) return 1; return 0; }
/* ARGSUSED */ static void aiohandler(int signo, siginfo_t *info, void *context) { int myerrno, mystatus, serrno; serrno = errno; myerrno = aio_error(&aiocb); if (myerrno == EINPROGRESS) { errno = serrno; return; } if (myerrno) { seterror(myerrno); errno = serrno; return; } mystatus = aio_return(&aiocb); totalbytes += mystatus; aiocb.aio_offset += mystatus; if (mystatus == 0) doneflag = 1; else if (r_write(fdout, (char *)aiocb.aio_buf, mystatus) == -1) seterror(errno); else if (readstart() == -1) seterror(errno); errno = serrno; }
ssize_t rWrite (struct r_file *file, char *o_buffer, ssize_t size) { int status = 0 , ret = -1 , siz = 0 , o_siz = 0 , flag = 0; unsigned long temp_size = 0 , bytes_read = 0 , temp_size1 = 0; unsigned long counter = 0; int start1 = 0 , start2 , copy_ptr; char buffer[1024]; size = strlen (o_buffer); if (file->write_flag == 0) { printf ("ERROR: File is Open in Read mode\n"); goto out; } temp_size = size; if (temp_size > 0) { if (file != NULL) { if (temp_size > 1000) { temp_size1 = size; flag = 1; loop: if (temp_size > 1000) { size = 1000; temp_size -= 1000; } else { size = temp_size; temp_size = 0; } } else size = temp_size; memset (buffer , 0 , sizeof(buffer)); for (start2 = 0, start1 = siz; start1 < (siz+size) && start2 <= 1000; start1++ , start2++) { buffer[start2] = o_buffer[start1]; } o_siz = siz; siz = r_write (file , buffer , size); if (siz == -1) { status = atoi(buffer); if (status == file_not_open) { printf ("ERROR: File Not Open\n"); printf ("\nWrite failed\n"); } else if (status == not_enough_content) { if (flag == 1) goto message; printf ("ERROR: Not Enough Content\n"); } else printf ("ERROR: Write Failed\n"); ret = -1; goto out; } else { if (flag == 1) { counter += siz; if (counter >= temp_size1) { ret = 0; goto message; } else { goto loop; } } else { printf ("Successfuly Written to the " "file\nNo. of bytes Written: " "%d\n" , siz); ret = 0; goto out; } } } else printf ("ERROR: File Not Open\n\n"); } else printf ("ERROR: Please Enter a Valid Size\n\n"); message: if (flag == 1) { if (counter == temp_size1) printf ("\n\nSuccessfuly Written to file\nNo. of bytes" " Written: %d\n" , counter); flag = 0; } out: memset(buffer , 0 , sizeof(buffer)); return ret; }
static void loopback_dec_thr_cb( void *arg) { int ret,maxFd ; struct timeval tv; fd_set writeset; H264_INF_T *h264_inf_ptr; frame_t *frame; struct NET_TASK *ev_task; single_pb_mgt *s_pb_mgt; struct NET_DATA_MGT_T *data_mgt; struct NET_DATA_NODE_T *data_node; ISIL_AV_PACKET *av_pck; s_pb_mgt = (single_pb_mgt *)arg; assert(s_pb_mgt); ev_task = s_pb_mgt->ev_task; assert(ev_task); data_mgt = ev_task->net_data_mgt; assert(data_mgt); s_pb_mgt->is_pb_thr_run = 1; maxFd = s_pb_mgt->video_fd +1; fprintf( stderr,"video fd [%d].\n",s_pb_mgt->video_fd ); while(s_pb_mgt->is_pb_thr_run ){ #if 0 FD_ZERO(&writeset); tv.tv_sec = 0; tv.tv_usec = DEC_SELECT_TIMEOUT; maxFd = s_pb_mgt->video_fd +1; ret = select(maxFd,NULL,&writeset,NULL,&tv); if( ret == 0 ) { if( errno == ETIMEDOUT ) { fprintf(stderr, "---select timeout--\n"); } else{ fprintf(stderr, "other result %d--\n", errno); } continue; } #endif data_node = data_mgt->get_net_data_node(data_mgt); if( !data_node ) { usleep(40000); continue; } av_pck = (ISIL_AV_PACKET *)data_node->arg; if( !av_pck ) { fprintf(stderr," Why : not av_pck ?.\n"); data_node->release(data_node); break; } if( !av_pck->buff || !av_pck->date_len) { fprintf(stderr," av_pck buff or len err.\n"); break; } if( !av_pck->priv ) { fprintf(stderr," av_pck priv NULL.\n"); break; } if( av_pck->frm_type != ISIL_H264_DATA ) { fprintf( stderr,"frm_type is not ISIL_H264_DATA ,is [%d].\n",av_pck->frm_type); break; } if( !s_pb_mgt->video_sync ) { h264_inf_ptr = &(av_pck->data_type_u.h264_inf); if( h264_inf_ptr->nalu_type != H264_NALU_IDRSLICE ) { fprintf( stderr,"nal is not H264_NALU_IDRSLICE ,or H264_NALU_ISLICE.\n"); goto LOOPBACK_RELEASE; } else{ s_pb_mgt->video_sync = 1; } } frame = (frame_t *)(av_pck->priv); //isil_av_packet_debug(av_pck); //fprintf( stderr,"len[%d],fd[%d] .\n",av_pck->date_len,s_pb_mgt->video_fd ); ret = r_write(s_pb_mgt->video_fd ,(char *)frame->buff,frame->len); if( ret < 0) { fprintf(stderr,"loop back write data err .\n"); data_node->release(data_node); break; } LOOPBACK_RELEASE: //DEBUG_FUNCTION(); data_node->release(data_node); } fprintf(stderr,"Loopback err ,exit .\n"); if( s_pb_mgt->release ) { s_pb_mgt->release(s_pb_mgt); } return ; }