void compflush(Obj p){ Obj cp = CDR(p); int i, l; switch (SUBSUBPORT(p)){ case COMP_T: case COMP_ECHO: case COMP_2WAY: Fflush( CAR(cp)); Fflush( CDR(cp)); break; case COMP_CONCAT: Fflush( CAR(cp)); break; case COMP_BCAST: l = CLENGTH(cp); for(i=0; i<l; i++) Fflush( CVECTOR(cp)[i] ); break; case COMP_SYNO: Fflush( getvalue(cp)); break; case COMP_FUNC: funcall_0("#<internal:compflush>", CVECTOR(cp)[2]); break; default: break; } }
/** * @todo Create transaction set *much* earlier. */ static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, const char * fmodeMacro) { char *failedFile = NULL; FD_t cfd; int fsmrc; (void) Fflush(fdo); cfd = Fdopen(fdDup(Fileno(fdo)), fmodeMacro); if (cfd == NULL) return RPMRC_FAIL; fsmrc = rpmPackageFilesArchive(csa->cpioList, headerIsSource(h), cfd, &csa->cpioArchiveSize, &failedFile); if (fsmrc) { if (failedFile) rpmlog(RPMLOG_ERR, _("create archive failed on file %s\n"), failedFile); else rpmlog(RPMLOG_ERR, _("create archive failed\n")); } free(failedFile); Fclose(cfd); return (fsmrc == 0) ? RPMRC_OK : RPMRC_FAIL; }
/*清除摄像头系统信息, 这里把内存的对应的所有数据都保存到了文件中*/ void camera_pro_system_close( void ) { /*写入配置文件*/ #if 0 camera_profile_format cmr_file; int write_byte = 0; write_byte = sizeof(preset_point_format)*PRESET_NUM_MAX; memcpy( cmr_file.cmr_preset_list, gpresetcmr_list, write_byte ); camera_profile_fill_check( &cmr_file, PRESET_NUM_MAX ); // 从头写入 if( -1 != Fseek( gpreset_fd, 0, SEEK_SET)) { camera_profile_write( gpreset_fd, &cmr_file ); Fflush( gpreset_fd ); } #endif /*2016-1-26不能正常关闭*/ if( gpreset_fd != NULL ) { DEBUG_INFO( "============>camera system close Success!<=======" ); camera_profile_close( gpreset_fd ); gpreset_fd = NULL; } DEBUG_INFO( "============>camera system close Success!<=======" ); }
/** * Copy header+payload, calculating digest(s) on the fly. * @param sfdp source file * @param sfnp source path * @param tfdp destination file * @param tfnp destination path */ static int copyFile(FD_t *sfdp, const char *sfnp, FD_t *tfdp, const char *tfnp) { unsigned char buf[BUFSIZ]; ssize_t count; int rc = 1; while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), *sfdp)) > 0) { if (Fwrite(buf, sizeof(buf[0]), count, *tfdp) != count) { rpmlog(RPMLOG_ERR, _("%s: Fwrite failed: %s\n"), tfnp, Fstrerror(*tfdp)); goto exit; } } if (count < 0) { rpmlog(RPMLOG_ERR, _("%s: Fread failed: %s\n"), sfnp, Fstrerror(*sfdp)); goto exit; } if (Fflush(*tfdp) != 0) { rpmlog(RPMLOG_ERR, _("%s: Fflush failed: %s\n"), tfnp, Fstrerror(*tfdp)); } rc = 0; exit: return rc; }
/** * @todo Create transaction set *much* earlier. */ static rpmRC cpio_doio(FD_t fdo, Package pkg, const char * fmodeMacro, rpm_loff_t *archiveSize) { char *failedFile = NULL; FD_t cfd; int fsmrc; (void) Fflush(fdo); cfd = Fdopen(fdDup(Fileno(fdo)), fmodeMacro); if (cfd == NULL) return RPMRC_FAIL; fsmrc = rpmPackageFilesArchive(pkg->cpioList, headerIsSource(pkg->header), cfd, pkg->dpaths, archiveSize, &failedFile); if (fsmrc) { char *emsg = rpmfileStrerror(fsmrc); if (failedFile) rpmlog(RPMLOG_ERR, _("create archive failed on file %s: %s\n"), failedFile, emsg); else rpmlog(RPMLOG_ERR, _("create archive failed: %s\n"), emsg); free(emsg); } free(failedFile); Fclose(cfd); return (fsmrc == 0) ? RPMRC_OK : RPMRC_FAIL; }
/** * @todo Create transaction set *much* earlier. */ static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, const char * fmodeMacro) { rpmts ts = rpmtsCreate(); rpmfi fi = csa->cpioList; rpmte te = NULL; rpmfs fs = NULL; char *failedFile = NULL; FD_t cfd; rpmRC rc = RPMRC_OK; int xx, i; { char *fmode = rpmExpand(fmodeMacro, NULL); if (!(fmode && fmode[0] == 'w')) fmode = xstrdup("w9.gzdio"); (void) Fflush(fdo); cfd = Fdopen(fdDup(Fileno(fdo)), fmode); fmode = _free(fmode); } if (cfd == NULL) return RPMRC_FAIL; /* make up a transaction element for passing to fsm */ rpmtsAddInstallElement(ts, h, NULL, 0, NULL); te = rpmtsElement(ts, 0); fs = rpmteGetFileStates(te); fi = rpmfiInit(fi, 0); while ((i = rpmfiNext(fi)) >= 0) { if (rpmfiFFlags(fi) & RPMFILE_GHOST) rpmfsSetAction(fs, i, FA_SKIP); else rpmfsSetAction(fs, i, FA_COPYOUT); } xx = fsmSetup(rpmfiFSM(fi), FSM_PKGBUILD, ts, te, fi, cfd, &csa->cpioArchiveSize, &failedFile); if (xx) rc = RPMRC_FAIL; (void) Fclose(cfd); xx = fsmTeardown(rpmfiFSM(fi)); if (rc == RPMRC_OK && xx) rc = RPMRC_FAIL; if (rc) { if (failedFile) rpmlog(RPMLOG_ERR, _("create archive failed on file %s: %s\n"), failedFile, cpioStrerror(rc)); else rpmlog(RPMLOG_ERR, _("create archive failed: %s\n"), cpioStrerror(rc)); rc = RPMRC_FAIL; } rpmtsEmpty(ts); failedFile = _free(failedFile); ts = rpmtsFree(ts); return rc; }
/************************************************* *Writer: YasirLiang *Date: 2016/2/17 *Name:control_matrix_recv_pro_byte_msg *Func: proccess byte recv matrix message:write byte data to file as so far(17-2-2017);后期可能修改 *Param:none *return value:none ***************************************************/ bool control_matrix_recv_pro_byte_msg( /*thost_upper_cmpt_msg *pmsg, */uint8_t save_char ) { bool bret = false; uint8_t save_ch = save_char; if( gmatrix_save_msg_fd != NULL ) { if( Fwrite( gmatrix_save_msg_fd, &save_ch, 1, 1 ) == 1 ); { Fflush( gmatrix_save_msg_fd ); bret = true; } } return bret; }
static PyObject *rpmfd_flush(rpmfdObject *s) { int rc; if (s->fd == NULL) return err_closed(); Py_BEGIN_ALLOW_THREADS rc = Fflush(s->fd); Py_END_ALLOW_THREADS if (rc || Ferror(s->fd)) { PyErr_SetString(PyExc_IOError, Fstrerror(s->fd)); return NULL; } Py_RETURN_NONE; }
static void CatchSignal(int sig) { #if SIGINT >= 0 (void) signal(SIGINT, SIG_IGN); #endif #if SIGHUP >= 0 (void) signal(SIGHUP, SIG_IGN); #endif #if SIGQUIT >= 0 (void) signal(SIGQUIT, SIG_IGN); #endif #if SIGALRM >= 0 (void) signal(SIGALRM, SIG_IGN); #endif #if SIGTERM >= 0 (void) signal(SIGTERM, SIG_IGN); #endif switch (sig) { case SIGHUP: case SIGALRM: Fflush(stdout); AppSignal(); break; case SIGINT: case SIGQUIT: case SIGTERM: default: Fprintf(stdout, "\n\n# Signal #%d: %s\n\n", sig, NameOfSignal(sig)); if (sig == SIGINT) { QuitProgram = 1; NoSIGINT = 1; AppSignal(); } else AppExit(2); break; } }
static rpmRC writeHdr(FD_t fd, Header pkgh) { /* Reallocate the header into one contiguous region for writing. */ Header h = headerReload(headerCopy(pkgh), RPMTAG_HEADERIMMUTABLE); rpmRC rc = RPMRC_FAIL; if (h == NULL) { rpmlog(RPMLOG_ERR,_("Unable to create immutable header region\n")); goto exit; } if (headerWrite(fd, h, HEADER_MAGIC_YES)) { rpmlog(RPMLOG_ERR, _("Unable to write header to %s: %s\n"), Fdescr(fd), Fstrerror(fd)); goto exit; } (void) Fflush(fd); rc = RPMRC_OK; exit: headerFree(h); return rc; }
static rpmRC writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName, CSA_t csa, char **cookie) { FD_t fd = NULL; FD_t ifd = NULL; ssize_t count; char * sigtarget = NULL;; char * rpmio_flags = NULL; char * SHA1 = NULL; const char *s; char *buf = NULL; Header h; Header sig = NULL; int xx; rpmRC rc = RPMRC_OK; struct rpmtd_s td; rpmTagVal sizetag; rpmTagVal payloadtag; /* Transfer header reference form *hdrp to h. */ h = headerLink(*hdrp); *hdrp = headerFree(*hdrp); if (pkgidp) *pkgidp = NULL; /* Save payload information */ if (headerIsSource(h)) rpmio_flags = rpmExpand("%{?_source_payload}", NULL); else rpmio_flags = rpmExpand("%{?_binary_payload}", NULL); if (!(rpmio_flags && *rpmio_flags)) { rpmio_flags = _free(rpmio_flags); rpmio_flags = xstrdup("w9.gzdio"); } s = strchr(rpmio_flags, '.'); if (s) { const char *compr = NULL; headerPutString(h, RPMTAG_PAYLOADFORMAT, "cpio"); if (rstreq(s+1, "ufdio")) { compr = NULL; } else if (rstreq(s+1, "gzdio")) { compr = "gzip"; #if HAVE_BZLIB_H } else if (rstreq(s+1, "bzdio")) { compr = "bzip2"; /* Add prereq on rpm version that understands bzip2 payloads */ (void) rpmlibNeedsFeature(h, "PayloadIsBzip2", "3.0.5-1"); #endif #if HAVE_LZMA_H } else if (rstreq(s+1, "xzdio")) { compr = "xz"; (void) rpmlibNeedsFeature(h, "PayloadIsXz", "5.2-1"); } else if (rstreq(s+1, "lzdio")) { compr = "lzma"; (void) rpmlibNeedsFeature(h, "PayloadIsLzma", "4.4.6-1"); #endif } else { rpmlog(RPMLOG_ERR, _("Unknown payload compression: %s\n"), rpmio_flags); rc = RPMRC_FAIL; goto exit; } if (compr) headerPutString(h, RPMTAG_PAYLOADCOMPRESSOR, compr); buf = xstrdup(rpmio_flags); buf[s - rpmio_flags] = '\0'; headerPutString(h, RPMTAG_PAYLOADFLAGS, buf+1); free(buf); } /* Create and add the cookie */ if (cookie) { rasprintf(cookie, "%s %d", buildHost(), (int) (*getBuildTime())); headerPutString(h, RPMTAG_COOKIE, *cookie); } /* Reallocate the header into one contiguous region. */ h = headerReload(h, RPMTAG_HEADERIMMUTABLE); if (h == NULL) { /* XXX can't happen */ rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to create immutable header region.\n")); goto exit; } /* Re-reference reallocated header. */ *hdrp = headerLink(h); /* * Write the header+archive into a temp file so that the size of * archive (after compression) can be added to the header. */ fd = rpmMkTempFile(NULL, &sigtarget); if (fd == NULL || Ferror(fd)) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to open temp file.\n")); goto exit; } fdInitDigest(fd, PGPHASHALGO_SHA1, 0); if (headerWrite(fd, h, HEADER_MAGIC_YES)) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to write temp header\n")); } else { /* Write the archive and get the size */ (void) Fflush(fd); fdFiniDigest(fd, PGPHASHALGO_SHA1, (void **)&SHA1, NULL, 1); if (csa->cpioList != NULL) { rc = cpio_doio(fd, h, csa, rpmio_flags); } else if (Fileno(csa->cpioFdIn) >= 0) { rc = cpio_copy(fd, csa); } else { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Bad CSA data\n")); } } if (rc != RPMRC_OK) goto exit; (void) Fclose(fd); fd = NULL; (void) unlink(fileName); /* Generate the signature */ (void) fflush(stdout); sig = rpmNewSignature(); /* * There should be rpmlib() dependency on this, but that doesn't * really do much good as these are signature tags that get read * way before dependency checking has a chance to figure out anything. * On the positive side, not inserting the 32bit tag at all means * older rpm will just bail out with error message on attempt to read * such a package. */ if (csa->cpioArchiveSize < UINT32_MAX) { sizetag = RPMSIGTAG_SIZE; payloadtag = RPMSIGTAG_PAYLOADSIZE; } else { sizetag = RPMSIGTAG_LONGSIZE; payloadtag = RPMSIGTAG_LONGARCHIVESIZE; } (void) rpmGenDigest(sig, sigtarget, sizetag); (void) rpmGenDigest(sig, sigtarget, RPMSIGTAG_MD5); if (SHA1) { /* XXX can't use rpmtdFromFoo() on RPMSIGTAG_* items */ rpmtdReset(&td); td.tag = RPMSIGTAG_SHA1; td.type = RPM_STRING_TYPE; td.data = SHA1; td.count = 1; headerPut(sig, &td, HEADERPUT_DEFAULT); SHA1 = _free(SHA1); } { /* XXX can't use headerPutType() on legacy RPMSIGTAG_* items */ rpmtdReset(&td); td.tag = payloadtag; td.count = 1; if (payloadtag == RPMSIGTAG_PAYLOADSIZE) { rpm_off_t asize = csa->cpioArchiveSize; td.type = RPM_INT32_TYPE; td.data = &asize; headerPut(sig, &td, HEADERPUT_DEFAULT); } else { rpm_loff_t asize = csa->cpioArchiveSize; td.type = RPM_INT64_TYPE; td.data = &asize; headerPut(sig, &td, HEADERPUT_DEFAULT); } } /* Reallocate the signature into one contiguous region. */ sig = headerReload(sig, RPMTAG_HEADERSIGNATURES); if (sig == NULL) { /* XXX can't happen */ rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to reload signature header.\n")); goto exit; } /* Open the output file */ fd = Fopen(fileName, "w.ufdio"); if (fd == NULL || Ferror(fd)) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Could not open %s: %s\n"), fileName, Fstrerror(fd)); goto exit; } /* Write the lead section into the package. */ { rpmlead lead = rpmLeadFromHeader(h); rc = rpmLeadWrite(fd, lead); lead = rpmLeadFree(lead); if (rc != RPMRC_OK) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to write package: %s\n"), Fstrerror(fd)); goto exit; } } /* Write the signature section into the package. */ if (rpmWriteSignature(fd, sig)) { rc = RPMRC_FAIL; goto exit; } /* Append the header and archive */ ifd = Fopen(sigtarget, "r.ufdio"); if (ifd == NULL || Ferror(ifd)) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to open sigtarget %s: %s\n"), sigtarget, Fstrerror(ifd)); goto exit; } /* Add signatures to header, and write header into the package. */ /* XXX header+payload digests/signatures might be checked again here. */ { Header nh = headerRead(ifd, HEADER_MAGIC_YES); if (nh == NULL) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to read header from %s: %s\n"), sigtarget, Fstrerror(ifd)); goto exit; } #ifdef NOTYET (void) headerMergeLegacySigs(nh, sig); #endif xx = headerWrite(fd, nh, HEADER_MAGIC_YES); nh = headerFree(nh); if (xx) { rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to write header to %s: %s\n"), fileName, Fstrerror(fd)); goto exit; } } /* Write the payload into the package. */ buf = xmalloc(BUFSIZ); while ((count = Fread(buf, 1, BUFSIZ, ifd)) > 0) { if (count == -1) { free(buf); rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to read payload from %s: %s\n"), sigtarget, Fstrerror(ifd)); goto exit; } if (Fwrite(buf, sizeof(buf[0]), count, fd) != count) { free(buf); rc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("Unable to write payload to %s: %s\n"), fileName, Fstrerror(fd)); goto exit; } } free(buf); rc = RPMRC_OK; exit: rpmio_flags = _free(rpmio_flags); SHA1 = _free(SHA1); h = headerFree(h); /* XXX Fish the pkgid out of the signature header. */ if (sig != NULL && pkgidp != NULL) { struct rpmtd_s md5tag; headerGet(sig, RPMSIGTAG_MD5, &md5tag, HEADERGET_DEFAULT); if (rpmtdType(&md5tag) == RPM_BIN_TYPE && md5tag.count == 16 && md5tag.data != NULL) { *pkgidp = md5tag.data; } } sig = rpmFreeSignature(sig); if (ifd) { (void) Fclose(ifd); ifd = NULL; } if (fd) { (void) Fclose(fd); fd = NULL; } if (sigtarget) { (void) unlink(sigtarget); sigtarget = _free(sigtarget); } if (rc == RPMRC_OK) rpmlog(RPMLOG_NOTICE, _("Wrote: %s\n"), fileName); else (void) unlink(fileName); return rc; }
void TriaLoop(int MaximumTrials, int nTrialsPerPhaseSet) { T_PhaseCode *PhaseCode, *FixedCode; T_FourierParameters FP[1]; T_PeakFlags *PeakFlags; Fprec *Surface; int StatLoadNextPhaseSet, iTrialsPerPhaseSet; long PosLoadNextPhaseSet; T_Ticks Ticks; long CheckTime = -SignalFileCheckInterval; nTrials = 0; nConvergedPhases = 0; nNotConvergedPhases = 0; StatLoadNextPhaseSet = 0; PosLoadNextPhaseSet = 1; iTrialsPerPhaseSet = 0; CheckMalloc(PhaseCode, nActivePhase); FixedCode = NULL; if (F_PhaseSetsFileName) CheckMalloc(FixedCode, nActivePhase); InitFourierParameters(FP, CodeTransl, nActivePhase); CheckMalloc(PeakFlags, Nx * Ny * Nz); DS_MarkEquiv(&SpgrInfo, PeakFlags, Nx, Ny, Nz); Surface = NULL; if (F_SurfaceFileName) { CheckMalloc(Surface, Nx * Ny * Nz); LoadSurface(Surface, Nx, Ny, Nz, PeakFlags); } /* initialize random number generator */ DoRandomInitialization(); (void) GetTicks(&Ticks); PrintTicks(stdout, &Ticks, "# Time ", " Start of TriaLoop\n"); Fflush(stdout); for (;;) { if (F_SignalFileName) { if (Ticks.sec_since_some_day - CheckTime >= SignalFileCheckInterval) { CheckSignalFile(); CheckTime = Ticks.sec_since_some_day; } } if (QuitProgram) break; if ( FixedCode && ( StatLoadNextPhaseSet == 0 || iTrialsPerPhaseSet >= nTrialsPerPhaseSet)) { PosLoadNextPhaseSet = LoadNextPhaseSet(NULL) + 1; Fprintf(stdout, "# Looking for next phase set, starting at line #%ld in file %s\n", PosLoadNextPhaseSet, F_PhaseSetsFileName); StatLoadNextPhaseSet = LoadNextPhaseSet(FixedCode); if (StatLoadNextPhaseSet == -1) break; iTrialsPerPhaseSet = 0; } Fprintf(stdout, "WoT %d", nTrials); if (FixedCode) Fprintf(stdout, " PosPhaseSet %ld Fixed %ld Random %d Trial %d", PosLoadNextPhaseSet, (long) nActivePhase - StatLoadNextPhaseSet, StatLoadNextPhaseSet, iTrialsPerPhaseSet); putc('\n', stdout); Fflush(stdout); CurrPhaseCode_nCallRanmar = NextPhaseCode(PhaseCode, FixedCode); RecyclePhases(FP, PeakFlags, Surface, PhaseCode); nTrials++; if (FixedCode) iTrialsPerPhaseSet++; (void) GetTicks(&Ticks); PrintTicks(stdout, &Ticks, "# Time ", "\n"); Fflush(stdout); if (MaximumTrials && MaximumTrials <= nTrials) break; } if (Surface) AppFree(Surface, Nx * Ny * Nz); AppFree(PeakFlags, Nx * Ny * Nz); FreeFourierParameters(FP); PrintTicks(stdout, NULL, "# Time ", " End of TriaLoop\n"); }
/********************************** **Writer:YasirLiang **Date:2015-12-8 **Name:camera_preset_save **Param: ** cmd:0 ** data:NULL ** data_len:0 **Return Value: -1:Error **State:在当前预置参数gcurpresetcmr中保存终 ** 端的预置位 ************************************/ int camera_preset_save( uint16_t cmd, void *data, uint32_t data_len ) { uint16_t index = 0; uint8_t preset = 0; DEBUG_INFO( "=====gcurpresetcmr.tmnl_addr = 0x%04x", gcurpresetcmr.tmnl_addr ); if( 0xffff == gcurpresetcmr.tmnl_addr ) { return -1; } if( camera_preset_list_exit_addr( gcurpresetcmr.tmnl_addr, &index)) { gpresetcmr_list[index].preset_point_num = 0xff; if( !camera_prese_num(gcurpresetcmr.camera_num, &preset )) { return -1; } gcurpresetcmr.preset_point_num = preset; } else if( camera_preset_list_exit_addr(0xffff, &index) ) { gpresetcmr_list[index].preset_point_num = 0xff; gpresetcmr_list[index].camera_num = 0xff; if( !camera_prese_num(gcurpresetcmr.camera_num, &preset) ) { return -1; } gcurpresetcmr.preset_point_num = preset; } else { DEBUG_INFO( "not find preset addr!" ); return -1; } gpresetcmr_list[index].camera_num = gcurpresetcmr.camera_num; gpresetcmr_list[index].preset_point_num = gcurpresetcmr.preset_point_num; gpresetcmr_list[index].tmnl_addr = gcurpresetcmr.tmnl_addr; DEBUG_INFO( "index in gpresetcmr_list = %d, [0x%04x-%d-%d]", index, gpresetcmr_list[index].tmnl_addr, gpresetcmr_list[index].camera_num, gpresetcmr_list[index].preset_point_num ); camera_pro_control( gcurpresetcmr.camera_num, CAMERA_CTRL_PRESET_SET, 0,\ gcurpresetcmr.preset_point_num ); camera_profile_format cmr_file; int write_byte = 0; write_byte = sizeof(preset_point_format)*PRESET_NUM_MAX; memcpy( cmr_file.cmr_preset_list, gpresetcmr_list, write_byte ); camera_profile_fill_check( &cmr_file, PRESET_NUM_MAX ); if( -1 != Fseek(gpreset_fd, 0, SEEK_SET) ) { camera_profile_write( gpreset_fd, &cmr_file ); Fflush( gpreset_fd ); } #ifdef __CAMERA_DEBUG__ preset_camera_list_info(); #endif if((gcurpresetcmr.tmnl_addr != FULL_VIEW_ADDR) && (gcurpresetcmr.tmnl_addr != BACKUP_FULL_VIEW_ADDR)) {//非全景定位保存预置后需要熄灭相应终端的指示灯 tmnl_pdblist close_node = found_terminal_dblist_node_by_addr( gcurpresetcmr.tmnl_addr ); // 注: ====>>>这里也操作了终端链表<<<<<<<<===== trans_model_unit_disconnect( close_node->tmnl_dev.entity_id, close_node ); } return 0; }
int PerlIO_flush(PerlIO *f) { return Fflush(f); }
// 20-2-2016 添加数据库的相关处理 int proccess_upper_cmpt_discussion_parameter( uint16_t protocol_type, void *data, uint32_t data_len ) //后期可能需要修改11/10。 { tcmpt_discuss_parameter qu_dis_para, set_dis_para; uint16_t send_data_len = 0; // 协议数据负载的长度 thost_system_set set_sys; // 系统配置文件的格式 if ( -1 == system_db_queue_configure_system_table( &set_sys )) { // load from memory(system.dat) memcpy( &set_sys, &gset_sys, sizeof(thost_system_set)); } if((protocol_type & CMPT_MSG_TYPE_MARK) == CMPT_MSG_TYPE_QUERY ) { qu_dis_para.chairman_first = set_sys.chman_first ? ENABLE_VAL : FORBID_VAL; qu_dis_para.chair_music = set_sys.chman_music ? ENABLE_VAL : FORBID_VAL; qu_dis_para.auto_close = set_sys.auto_close ? ENABLE_VAL : FORBID_VAL; qu_dis_para.discuss_mode = set_sys.discuss_mode & 0x07; qu_dis_para.limit_speak_num = set_sys.speak_limit & 0xff; qu_dis_para.limit_apply_num = set_sys.apply_limit & 0xff; qu_dis_para.limit_chm_time = set_sys.chman_limitime ? ENABLE_VAL : FORBID_VAL; qu_dis_para.limit_vip_time = set_sys.vip_limitime ? ENABLE_VAL : FORBID_VAL; qu_dis_para.limit_speak_time = set_sys.spk_limtime & 0x3f; send_data_len = sizeof(tcmpt_discuss_parameter); send_upper_computer_command( CMPT_MSG_TYPE_RESPONSE |CMPT_MSG_TYPE_QUERY, \ DISCUSSION_PARAMETER, &qu_dis_para, send_data_len ); } else if((protocol_type & CMPT_MSG_TYPE_MARK) == CMPT_MSG_TYPE_SET )// 设置保存系统状态值并设置系统状态 { get_host_upper_cmpt_data( &set_dis_para, data, CMPT_DATA_OFFSET, sizeof(tcmpt_discuss_parameter)); DEBUG_RECV( &set_dis_para, sizeof(tcmpt_discuss_parameter), "Dis Param "); send_upper_computer_command( CMPT_MSG_TYPE_RESPONSE |CMPT_MSG_TYPE_SET, \ DISCUSSION_PARAMETER, NULL, 0 ); // 第三个与第四个参数与协议有些出入,这里是根据黄工代码写的。协议是数据单元仅一个字节0,设置成功;非零设置失败。而黄工的没有数据单元,故这里写NULL if( set_dis_para.discuss_mode == UPPER_CMPT_DISCUSS_FREE_MODE )// 数字会议系统没有自由模式 { terminal_start_discuss( false ); return 0; } // 保存配置文件 if( (profile_dis_param_save_to_ram( &gset_sys, &set_dis_para ) != -1) && (-1 != profile_system_file_write_gb_param( profile_file_fd, &gset_sys )) ) { Fflush( profile_file_fd ); // 设置系统状态 uint8_t temp_status = set_dis_para.auto_close; if( temp_status != set_sys.auto_close ) { // 自动关闭麦克风 find_func_command_link( MENUMENT_USE, MENU_AUTO_CLOSE_CMD, 0, &temp_status, 1 ); } temp_status = set_dis_para.discuss_mode; if( temp_status != set_sys.discuss_mode ) { // 设置系统讨论模式 DEBUG_INFO("discuss mode = %d", temp_status); find_func_command_link( MENUMENT_USE, MENU_DISC_MODE_SET_CMD, 0, &temp_status, 1 ); } temp_status = set_dis_para.limit_speak_num; if( temp_status != set_sys.speak_limit ) { // 设置限制的发言人数 find_func_command_link( MENUMENT_USE, MENU_SPK_LIMIT_NUM_SET, 0, &temp_status, 1 ); } temp_status = set_dis_para.limit_apply_num; if( temp_status != set_sys.apply_limit ) { // 设置限制申请人数 find_func_command_link( MENUMENT_USE, MUNU_APPLY_LIMIT_NUM_SET, 0, &temp_status, 1 ); } // 限时设置 terminal_limit_speak_time_set( 0, NULL, 0 ); // 设置会议讨论状态 terminal_start_discuss( false ); //更新数据库系统配置信息 system_db_update_configure_system_table( gset_sys ); } } terminal_main_state_send( 0, NULL, 0 ); return 0; }
void score_init() { register char *s; register int i; FILE *savfil; if (stat(SAVEDIR,&filestat)) { printf("Cannot access %s\r\n",SAVEDIR); finalize(1); } if (filestat.st_uid != geteuid()) { printf("Warp will not run right without being setuid.\r\n"); finalize(1); } if ((filestat.st_mode & 0605) != 0605) { printf("%s is not protected correctly (must be u+rw o+rx).\r\n",SAVEDIR); finalize(1); } interp(longlognam, sizeof longlognam, "%L"); for (i=strlen(longlognam); i<8; i++) longlognam[i] = ' '; /* make sure it is 8 long for strncmp */ longlognam[8] = '\0'; if (scorespec) wscore(); Sprintf(savefilename, "save.%s", logname); savfil = experimenting ? NULL : fopen(savefilename,"r"); if (savfil != NULL && fgets(spbuf,100,savfil) != NULL) { char tmpbuf[80]; spbuf[strlen(spbuf)-1] = '\0'; if (fgets(tmpbuf,80,savfil) != NULL) { int processnum; tmpbuf[strlen(tmpbuf)-1] = '\0'; printf("You seem to have left a game %s.\r\n",tmpbuf+9); s = strchr(tmpbuf+9, ','); *s = '\0'; processnum = atoi(s+11); if (kill(processnum, SIGINT)) { /* does process not exist? */ /* (warp ignores SIGINT) */ printf("\r\n\ That process does not seem to exist anymore, so you'll have to start the\r\n"); printf( "last wave over.\r\n\n"); printf( " [type anything to continue]"); Fflush(stdout); eat_typeahead(); getcmd(tmpbuf); if (*tmpbuf == INTRCH) finalize(0); printf("\r\n"); } else { if (strcmp(term+8,tmpbuf+23)) {
/* when vectorize = 0 */ void c_out(const char* prefix) { #if NMODL Item *q; extern int point_process; #endif Fprintf(fcout, "/* Created by Language version: %s */\n", nmodl_version_); Fflush(fcout); #if VECTORIZE if (vectorize) { vectorize_do_substitute(); kin_vect2(); /* heh, heh.. bet you can't guess what this is */ c_out_vectorize(prefix); return; } #endif #if VECTORIZE P("/* NOT VECTORIZED */\n"); #endif Fflush(fcout); /* things which must go first and most declarations */ #if SIMSYS P("#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n#include \"mathlib.h\"\n"); P("#include \"common.h\"\n#include \"softbus.h\"\n"); P("#include \"sbtypes.h\"\n#include \"Solver.h\"\n"); #else P("#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n#include \"scoplib_ansi.h\"\n"); P("#undef PI\n"); P("#define nil 0\n"); P("#include \"md1redef.h\"\n"); P("#include \"section.h\"\n"); P("#include \"nrniv_mf.h\"\n"); P("#include \"md2redef.h\"\n"); #endif printlist(defs_list); printlist(firstlist); P("static int _reset;\n"); #if NMODL P("static "); #endif if (modelline) { Fprintf(fcout, "char *modelname = \"%s\";\n\n", modelline); } else { Fprintf(fcout, "char *modelname = \"\";\n\n"); } Fflush(fcout); /* on certain internal errors partial output * is helpful */ P("static int error;\n"); #if NMODL P("static "); #endif P("int _ninits = 0;\n"); P("static int _match_recurse=1;\n"); #if NMODL P("static void "); #endif P("_modl_cleanup(){ _match_recurse=1;}\n"); /* * many machinations are required to make the infinite number of * definitions involving _p in defs.h to be invisible to the user */ /* * This one allows scop variables in functions which do not have the * p array as an argument */ #if SIMSYS || HMODL || NMODL #else P("static double *_p;\n\n"); #endif funcdec(); Fflush(fcout); /* * translations of named blocks into functions, procedures, etc. Also * some special declarations used by some blocks */ printlist(procfunc); Fflush(fcout); /* Initialization function must always be present */ #if NMODL P("\nstatic void initmodel() {\n int _i; double _save;"); #endif #if SIMSYS || HMODL P("\ninitmodel() {\n int _i; double _save;"); #endif #if (!(SIMSYS || HMODL || NMODL)) P("\ninitmodel(_pp) double _pp[]; {\n int _i; double _save; _p = _pp;"); #endif #if !NMODL P("_initlists();\n"); #endif P("_ninits++;\n"); P(saveindep); /*see solve.c; blank if not a time dependent process*/ P("{\n"); initstates(); printlist(initfunc); if (match_bound) { P("\n_init_match(_save);"); } P("\n}\n}\n"); Fflush(fcout); #if NMODL /* generation of initmodel interface */ #if VECTORIZE P("\nstatic void nrn_init(_NrnThread* _nt, _Memb_list* _ml, int _type){\n"); P("Node *_nd; double _v; int* _ni; int _iml, _cntml;\n"); P("#if CACHEVEC\n"); P(" _ni = _ml->_nodeindices;\n"); P("#endif\n"); P("_cntml = _ml->_nodecount;\n"); P("for (_iml = 0; _iml < _cntml; ++_iml) {\n"); P(" _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];\n"); #else P("\nstatic nrn_init(_prop, _v) Prop *_prop; double _v; {\n"); P(" _p = _prop->param; _ppvar = _prop->dparam;\n"); #endif if (debugging_ && net_receive_) { P(" _tsav = -1e20;\n"); } if (!artificial_cell) {ext_vdef();} if (!artificial_cell) {P(" v = _v;\n");} printlist(get_ion_variables(1)); P(" initmodel();\n"); printlist(set_ion_variables(2)); #if VECTORIZE P("}}\n"); #else P("}\n"); #endif /* standard modl EQUATION without solve computes current */ P("\nstatic double _nrn_current(double _v){double _current=0.;v=_v;"); #if CVODE if (cvode_nrn_current_solve_) { fprintf(fcout, "if (cvode_active_) { %s(); }\n", cvode_nrn_current_solve_->name); } #endif P("{"); if (currents->next != currents) { printlist(modelfunc); } ITERATE(q, currents) { Sprintf(buf, " _current += %s;\n", SYM(q)->name); P(buf); }