static void ch_setup(char *suffix) { int i; if (!sgr) { int *data,size,offset=0; char *filename=tempfile_name(suffix,"sgr"); printf("filename=%s\n",filename); sgr=file_create(filename,0); g_free(filename); dbg_assert(sgr != NULL); file_mmap(sgr); size=sizeof(int); data=(int *)file_data_read(sgr, offset, size); node_count=*data; offset+=size; size=node_count*sizeof(struct node); nodes=(struct node *)file_data_read(sgr, offset, size); offset+=size; size=sizeof(int); data=(int *)file_data_read(sgr, offset, size); edge_count=*data; offset+=size; size=edge_count*sizeof(struct edge); edges=(struct edge *)file_data_read(sgr, offset, size); offset+=size; size=sizeof(int); data=(int *)file_data_read(sgr, offset, size); newnode_count=*data; offset+=size; size=edge_count*sizeof(struct newnode); newnodes=(struct newnode *)file_data_read(sgr, offset, size); offset+=size; newnode_hash=g_hash_table_new(NULL, NULL); for (i = 0 ; i < newnode_count ; i++) { g_hash_table_insert(newnode_hash, GINT_TO_POINTER(newnodes[i].newnode), GINT_TO_POINTER(i)); } } if (!ddsg_node_index) { char *filename=tempfile_name(suffix,"ddsg_coords"); ddsg_node_index=file_create(filename,0); g_free(filename); dbg_assert(ddsg_node_index != NULL); file_mmap(ddsg_node_index); node_index=(struct coord *)file_data_read(ddsg_node_index, 0, file_size(ddsg_node_index)); } }
GLADE_CB void on_new_clicked (GtkToolButton *toolbutton, gpointer user_data) { CalcModel model; int result; result = msgbox_three(_("TiGroup"), _("Single/Group"), _("File type?")); if(!result) return; model = msgbox_model(); if(!model) return; file_create(result == MSGBOX_BUTTON1 ? TIFILE_TIGROUP : TIFILE_GROUP, model); g_free(GFMFile.filename); GFMFile.filename = NULL; enable_save(FALSE); enable_tree(TRUE); ctree_refresh(); labels_refresh(); }
static SFFILEH statflag_create(const OEMCHAR *filename) { SFFILEH ret; FILEH fh; ret = (SFFILEH)_MALLOC(sizeof(_SFFILEH), filename); if (ret == NULL) { goto sfc_err1; } fh = file_create(filename); if (fh == FILEH_INVALID) { goto sfc_err2; } if (file_write(fh, &np2flagdef, sizeof(NP2FHDR)) == sizeof(NP2FHDR)) { ZeroMemory(ret, sizeof(_SFFILEH)); ret->stat = SFFILEH_WRITE; ret->fh = fh; ret->secpos = sizeof(NP2FHDR); return(ret); } file_close(fh); file_delete(filename); sfc_err2: _MFREE(ret); sfc_err1: return(NULL); }
void newdisk_thd(const OEMCHAR *fname, UINT hddsize) { FILEH fh; UINT8 work[256]; UINT size; BRESULT r; if ((fname == NULL) || (hddsize < 5) || (hddsize > 256)) { goto ndthd_err; } fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndthd_err; } ZeroMemory(work, 256); size = hddsize * 15; STOREINTELWORD(work, size); r = (file_write(fh, work, 256) == 256) ? SUCCESS : FAILURE; r |= writehddipl(fh, 256, 0); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndthd_err: return; }
static int map_binfile_open(struct map_priv *m) { int *magic; struct zip_cd *first_cd; dbg(1,"file_create %s\n", m->filename); m->fi=file_create(m->filename); if (! m->fi) { dbg(0,"Failed to load '%s'\n", m->filename); return 0; } if (m->check_version) m->version=file_version(m->fi, m->check_version == 2); magic=(int *)file_data_read(m->fi, 0, 4); *magic = le32_to_cpu(*magic); if (*magic == zip_lfh_sig) { if ((m->eoc=binfile_read_eoc(m->fi)) && binfile_get_index(m) && (first_cd=binfile_read_cd(m, 0, 0))) { m->cde_size=sizeof(struct zip_cd)+first_cd->zipcfnl; m->zip_members=m->index_offset/m->cde_size+1; dbg(1,"cde_size %d\n", m->cde_size); dbg(1,"members %d\n",m->zip_members); file_data_free(m->fi, (unsigned char *)first_cd); } else { dbg(0,"invalid file format for '%s'\n", m->filename); return 0; } } else file_mmap(m->fi); file_data_free(m->fi, (unsigned char *)magic); m->cachedir="/tmp/navit"; return 1; }
static int tth_cache_file_create(const struct tth *tth) { char *pathname; int accmode; int fd; g_return_val_if_fail(tth, -1); accmode = O_WRONLY | O_TRUNC; pathname = tth_cache_pathname(tth); /* * Critical section required since we could have a concurrent thread * deciding to remove empty directories whilst we are attempting * to create a new directory to store the new cached entry! */ TTH_PATH_LOCK; fd = file_create_missing(pathname, accmode, TTH_FILE_MODE); if (fd < 0 && ENOENT == errno) { char *dir = filepath_directory(pathname); if (0 == create_directory(dir, DEFAULT_DIRECTORY_MODE)) { fd = file_create(pathname, accmode, TTH_FILE_MODE); } HFREE_NULL(dir); } TTH_PATH_UNLOCK; HFREE_NULL(pathname); return fd; }
/** * Creates * @param[in] lpFilename The filename * @param[in] nRate The sampling rate * @param[in] nBits The bits of the sample * @param[in] nChannels The number of the channels * @return The handle of wave */ WAVEFILEH wavefile_create(const OEMCHAR *lpFilename, UINT nRate, UINT nBits, UINT nChannels) { FILEH fh = FILEH_INVALID; WAVEFILEH hWave = NULL; do { if (lpFilename == NULL) { break; } if (nRate == 0) { break; } if ((nBits != 8) && (nBits != 16)) { break; } if ((nChannels != 1) && (nChannels != 2)) { break; } fh = file_create(lpFilename); if (fh == FILEH_INVALID) { break; } hWave = (WAVEFILEH)_MALLOC(sizeof(*hWave), "WAVEFILEH"); if (hWave == NULL) { break; } memset(hWave, 0, sizeof(*hWave)); hWave->fh = fh; hWave->nRate = nRate; hWave->nBits = nBits; hWave->nChannels = nChannels; if (WriteHeader(hWave) != SUCCESS) { break; } hWave->lpCurrent = hWave->buffer; hWave->nRemain = sizeof(hWave->buffer); return hWave; } while (FALSE /*CONSTCOND*/); if (hWave) { _MFREE(hWave); } if (fh != FILEH_INVALID) { file_close(fh); } return NULL; }
/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv) ***************************************************************************** * @b Description: Function called to uninitialize the plugin ***************************************************************************** * @param priv : pointer on the private data of the plugin ***************************************************************************** * @remarks private data is freed by this function (g_free) ***************************************************************************** **/ static void vehicle_file_destroy(struct vehicle_priv *priv) { if (priv->statefile && priv->nmea_data) { struct attr readwrite={attr_readwrite}; struct attr create={attr_create}; struct attr *attrs[]={&readwrite,&create,NULL}; struct file *f; readwrite.u.num=1; create.u.num=1; f=file_create(priv->statefile, attrs); if (f) { file_data_write(f, 0, strlen(priv->nmea_data), priv->nmea_data); file_destroy(f); } } vehicle_file_close(priv); callback_destroy(priv->cb); callback_destroy(priv->cbt); if (priv->statefile) g_free(priv->statefile); if (priv->source) g_free(priv->source); if (priv->buffer) g_free(priv->buffer); g_free(priv); }
void newdisk_vhd(const OEMCHAR *fname, UINT hddsize) { FILEH fh; VHDHDR vhd; UINT tmp; BRESULT r; if ((fname == NULL) || (hddsize < 2) || (hddsize > 512)) { goto ndvhd_err; } fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndvhd_err; } ZeroMemory(&vhd, sizeof(vhd)); CopyMemory(&vhd.sig, sig_vhd, 7); STOREINTELWORD(vhd.mbsize, (UINT16)hddsize); STOREINTELWORD(vhd.sectorsize, 256); vhd.sectors = 32; vhd.surfaces = 8; tmp = hddsize * 16; // = * 1024 * 1024 / (8 * 32 * 256); STOREINTELWORD(vhd.cylinders, (UINT16)tmp); tmp *= 8 * 32; STOREINTELDWORD(vhd.totals, tmp); r = (file_write(fh, &vhd, sizeof(vhd)) == sizeof(vhd)) ? SUCCESS : FAILURE; r |= writehddipl(fh, 256, 0); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndvhd_err: return; }
/** * Use specified random filler to create a file full of random bytes. * * @param path pathname where random data should be generated * @param rfn random number buffer-filling routine to use * @param len amount of random bytes to generate * * @return the amount of bytes generated if OK, a short count or -1 on error, * with errno set. */ ssize_t frand_save(const char *path, randfill_fn_t rfn, size_t len) { char buf[256]; int fd; ssize_t written = 0; fd = file_create(path, O_WRONLY, S_IRUSR | S_IWUSR); if (-1 == fd) return -1; while (len != 0) { size_t n = MIN(len, sizeof buf); ssize_t w; (*rfn)(buf, n); w = write(fd, buf, n); if (-1 == w) break; written += w; if (UNSIGNED(w) != n) break; len -= n; } ZERO(buf); /* Leave no memory trail */ close(fd); return written; }
void newdisk_nhd(const OEMCHAR *fname, UINT hddsize) { FILEH fh; NHDHDR nhd; UINT size; BRESULT r; if ((fname == NULL) || (hddsize < 5) || (hddsize > 512)) { goto ndnhd_err; } fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndnhd_err; } ZeroMemory(&nhd, sizeof(nhd)); CopyMemory(&nhd.sig, sig_nhd, 15); STOREINTELDWORD(nhd.headersize, sizeof(nhd)); size = hddsize * 15; STOREINTELDWORD(nhd.cylinders, size); STOREINTELWORD(nhd.surfaces, 8); STOREINTELWORD(nhd.sectors, 17); STOREINTELWORD(nhd.sectorsize, 512); r = (file_write(fh, &nhd, sizeof(nhd)) == sizeof(nhd)) ? SUCCESS : FAILURE; r |= writehddipl(fh, 512, size * 8 * 17 * 512); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndnhd_err: return; }
void debugpageptr(UINT32 addr) { FILEH fh; char buf[256]; UINT32 pde; UINT32 pte; UINT i; UINT32 a; fh = file_create("page.txt"); SPRINTF(buf, "CR3=%.8x\r\n", CPU_CR3); file_write(fh, buf, strlen(buf)); for (i=0; i<1024; i++) { a = CPU_STAT_PDE_BASE + (i * 4); pde = cpu_memoryread_d(a); SPRINTF(buf, "%.8x=>%.8x [%.8x]\r\n", (i << 22), pde, a); file_write(fh, buf, strlen(buf)); } addr >>= 22; pde = cpu_memoryread_d(CPU_STAT_PDE_BASE + (addr * 4)); for (i=0; i<1024; i++) { a = (pde & CPU_PDE_BASEADDR_MASK) + (i * 4); pte = cpu_memoryread_d(a); SPRINTF(buf, "%.8x=>%.8x [%.8x]\r\n", (addr << 22) + (i << 12), pte, a); file_write(fh, buf, strlen(buf)); } file_close(fh); }
static int wallet_save_keys(struct wallet *wallet) { struct config *cfg; int res; int n; n = hashtable_getnumentries(wallet->hash_keys); Log(LGPFX" saving %u key%s in %sencrypted wallet %s.\n", n, n > 1 ? "s" : "", wallet->pass ? "encrypted" : "NON-", wallet->filename); cfg = config_create(); config_setint64(cfg, n, "numKeys"); if (wallet->pass) { char saltStr[80]; int64 count = 0; bool s; res = RAND_bytes(wallet->ckey->salt, sizeof wallet->ckey->salt); if (res != 1) { res = ERR_get_error(); Log(LGPFX" RAND_bytes failed: %d\n", res); goto exit; } str_snprintf_bytes(saltStr, sizeof saltStr, NULL, wallet->ckey->salt, sizeof wallet->ckey->salt); config_setstring(cfg, saltStr, "encryption.salt"); s = crypt_set_key_from_passphrase(wallet->pass, wallet->ckey, &count); ASSERT(s); ASSERT(count >= CRYPT_NUM_ITERATIONS_OLD); config_setint64(cfg, count, "encryption.numIterations"); } hashtable_for_each(wallet->hash_keys, wallet_save_key_cb, cfg); file_rotate(wallet->filename, 1); res = file_create(wallet->filename); if (res) { Log(LGPFX" failed to create file '%s': %s\n", wallet->filename, strerror(res)); goto exit; } res = file_chmod(wallet->filename, 0600); if (res) { Log(LGPFX" failed to chmod 0600 wallet.dat: %s\n", strerror(res)); goto exit; } res = config_write(cfg, wallet->filename); exit: config_free(cfg); return res; }
char line_assimilate (void) { /*---(locals)-----------+-----------+-*/ char rce = -10; int rc = 0; /*---(header)-------------------------*/ DEBUG_INPT yLOG_enter (__FUNCTION__); /*---(create file)--------------------*/ rc = file_create (); DEBUG_INPT yLOG_value ("file" , rc); --rce; if (rc < 0) { DEBUG_INPT yLOG_exitr (__FUNCTION__, rce); return rce; } /*---(open file)----------------------*/ DEBUG_INPT yLOG_info ("f_full" , my.f_full); rc = yPARSE_open_in (my.f_full); DEBUG_INPT yLOG_value ("open" , rc); --rce; if (rc < 0) { DEBUG_INPT yLOG_exitr (__FUNCTION__, rce); return rce; } /*---(lines)--------------------------*/ while (rc >= 0) { rc = yPARSE_read (&my.t_recdno, NULL); DEBUG_INPT yLOG_value ("yparse" , rc); if (rc == 0) { DEBUG_INPT yLOG_note ("end-of-file"); break; } --rce; if (rc < 0) { DEBUG_INPT yLOG_exitr (__FUNCTION__, rce); return rce; } rc = line_parse (); DEBUG_INPT yLOG_value ("parse" , rc); --rce; if (rc < 0) { DEBUG_INPT yLOG_exitr (__FUNCTION__, rce); return rce; } rc = line_create (); DEBUG_INPT yLOG_value ("data" , rc); --rce; if (rc < 0) { DEBUG_INPT yLOG_exitr (__FUNCTION__, rce); return rce; } } /*---(close file)---------------------*/ rc = yPARSE_close_in (); DEBUG_INPT yLOG_value ("close" , rc); --rce; if (rc < 0) { DEBUG_INPT yLOG_exitr (__FUNCTION__, rce); return rce; } /*---(complete)-----------------------*/ DEBUG_INPT yLOG_exit (__FUNCTION__); return 0; }
static void trfh_open(const TCHAR *fname) { trfh_close(); tracewin.fh = file_create(fname); #if defined(FILEBUFSIZE) filebufpos = 0; #endif }
FILEH file_create_c(const OEMCHAR *filename) { *curfilep = '\0'; file_catname(curpath, filename, sizeof(curpath)); return file_create(curpath); }
BRESULT S98_open(const OEMCHAR *filename) { UINT i; S98HDR hdr; // ファイルのオープン s98log.fh = file_create(filename); if (s98log.fh == FILEH_INVALID) { return(FAILURE); } // 初期化 s98log.clock = pccore.realclock / 1000; s98log.p = 0; // ヘッダの保存 ZeroMemory(&hdr, sizeof(hdr)); hdr.magic[0] = 'S'; hdr.magic[1] = '9'; hdr.magic[2] = '8'; hdr.formatversion = '1'; STOREINTELDWORD(hdr.timerinfo, 1); STOREINTELDWORD(hdr.offset, offsetof(S98HDR, title)); STOREINTELDWORD(hdr.dumpdata, sizeof(S98HDR)); for (i=0; i<sizeof(hdr); i++) { S98_putc(*(((UINT8 *)&hdr) + i)); } #if 1 // FM for (i = 0x30; i < 0xb8; i++) { if ((i & 3) != 3) { S98_putc(NORMAL2608); S98_putc((REG8)i); S98_putc(g_opna[0].s.reg[i]); S98_putc(EXTEND2608); S98_putc((REG8)i); S98_putc(g_opna[0].s.reg[i+0x100]); } } // PSG for (i = 0x00; i < 0x0e; i++) { S98_putc(NORMAL2608); S98_putc((REG8)i); S98_putc(g_opna[0].s.reg[i]); } #endif // 一応パディング s98log.intcount = 10; sets98event(NEVENT_ABSOLUTE); return(SUCCESS); }
int gsiftp_create(char *filename, int *handle) { if (gsiftpurl) free(gsiftpurl); gsiftpurl = strdup(filename); return file_create(gsiftp_tmpfile, handle); }
static bool sys_save_settings(struct System* sys) { File f; file_create(&f, false); if(!file_open(&f, SETTINGS_FILE, sys->e->_saveDir, "wb")) { return false; } file_write(&f, &sys->settings, sizeof(sys->settings)); file_close(&f); return true; }
static bool sys_load_settings(struct System* sys) { File f; file_create(&f, false); if(!file_open(&f, SETTINGS_FILE, sys->e->_saveDir, "rb")) { return false; } file_read(&f, &sys->settings, sizeof(sys->settings)); file_close(&f); sys_rotate_keymap(sys); return true; }
int file_get_contents(char *name, unsigned char **buffer, int *size) { struct file *file; file=file_create(name, 0); if (!file) return 0; file->cache=0; *size=file_size(file); *buffer=file_data_read_all(file); file_destroy(file); return 1; }
static int zfs_create_vdev(struct mkfs_opts *mop, char *vdev) { int ret = 0; /* Silently ignore reserved vdev names */ if ((strncmp(vdev, "disk", 4) == 0) || (strncmp(vdev, "file", 4) == 0) || (strncmp(vdev, "mirror", 6) == 0) || (strncmp(vdev, "raidz", 5) == 0) || (strncmp(vdev, "spare", 5) == 0) || (strncmp(vdev, "log", 3) == 0) || (strncmp(vdev, "cache", 5) == 0)) return ret; /* * Verify a file exists at the provided absolute path. If it doesn't * and mo_device_sz is set attempt to create a file vdev to be used. * Relative paths will be passed directly to 'zpool create' which * will check multiple multiple locations under /dev/. */ if (vdev[0] == '/') { ret = access(vdev, F_OK); if (ret == 0) return ret; ret = errno; if (ret != ENOENT) { fatal(); fprintf(stderr, "Unable to access required vdev " "for pool %s (%d)\n", vdev, ret); return ret; } if (mop->mo_device_sz == 0) { fatal(); fprintf(stderr, "Unable to create vdev due to " "missing --device-size=#N(KB) parameter\n"); return EINVAL; } ret = file_create(vdev, mop->mo_device_sz); if (ret) { fatal(); fprintf(stderr, "Unable to create vdev %s (%d)\n", vdev, ret); return ret; } } return ret; }
struct file * file_create_caseinsensitive(char *name, struct attr **options) { char *dirname=g_alloca(sizeof(char)*(strlen(name)+1)); char *filename; char *p; void *d; struct file *ret; ret=file_create(name, options); if (ret) return ret; strcpy(dirname, name); p=dirname+strlen(name); while (p > dirname) { if (*p == '/') break; p--; } *p=0; d=file_opendir(dirname); if (d) { *p++='/'; while ((filename=file_readdir(d))) { if (!g_strcasecmp(filename, p)) { strcpy(p, filename); ret=file_create(dirname, options); if (ret) break; } } file_closedir(d); } return ret; }
struct file * file_create_caseinsensitive(char *name) { char dirname[strlen(name)+1]; char *filename; char *p; void *d; struct file *ret; ret=file_create(name); if (ret) return ret; strcpy(dirname, name); p=dirname+strlen(name); while (p > dirname) { if (*p == '/') break; p--; } *p=0; d=file_opendir(dirname); if (d) { *p++='/'; while ((filename=file_readdir(d))) { if (!strcasecmp(filename, p)) { strcpy(p, filename); ret=file_create(dirname); if (ret) break; } } file_closedir(d); } return ret; }
static int test_file_create() { int e; FILE *file; char filename[] = "/tmp/test-file-XXXXXXXX"; e = mkstemp(filename); e = file_create(filename, &file); assert(e == 0); assert(file); fclose(file); remove(filename); return 0; }
void load(SHARED_CONFIG *cfg, const char *name) { WT_CONNECTION *conn; WT_CURSOR *cursor; WT_ITEM *value, _value; WT_SESSION *session; size_t len; uint64_t keyno; char keybuf[64], valuebuf[64]; conn = cfg->conn; file_create(cfg, name); testutil_check(conn->open_session(conn, NULL, NULL, &session)); testutil_check( session->open_cursor(session, name, NULL, "bulk", &cursor)); value = &_value; for (keyno = 1; keyno <= cfg->nkeys; ++keyno) { if (cfg->ftype == ROW) { testutil_check(__wt_snprintf( keybuf, sizeof(keybuf), "%016" PRIu64, keyno)); cursor->set_key(cursor, keybuf); } else cursor->set_key(cursor, (uint32_t)keyno); value->data = valuebuf; if (cfg->ftype == FIX) cursor->set_value(cursor, 0x01); else { testutil_check(__wt_snprintf_len_set( valuebuf, sizeof(valuebuf), &len, "%37" PRIu64, keyno)); value->size = (uint32_t)len; cursor->set_value(cursor, value); } testutil_check(cursor->insert(cursor)); } /* Setup the starting key range for the workload phase. */ cfg->key_range = cfg->nkeys; testutil_check(cursor->close(cursor)); testutil_check(session->checkpoint(session, NULL)); testutil_check(session->close(session, NULL)); }
/* test retrieving OID from a file apart from the ODB */ void test_status_single__hash_single_file(void) { static const char file_name[] = "new_file"; static const char file_contents[] = "new_file\n"; static const char file_hash[] = "d4fa8600b4f37d7516bef4816ae2c64dbf029e3a"; git_oid expected_id, actual_id; /* initialization */ git_oid_fromstr(&expected_id, file_hash); file_create(file_name, file_contents); cl_set_cleanup(&cleanup__remove_file, (void *)file_name); cl_git_pass(git_odb_hashfile(&actual_id, file_name, GIT_OBJ_BLOB)); cl_assert(git_oid_cmp(&expected_id, &actual_id) == 0); }
bool Buyer::Creatinfo() { string username,userkey; cout<<"Please enter a user account:";cin>>username; cout<<"Please enter a user password:"******"[username] "<<username<<endl; file_create<<"[userkey] "<<userkey<<endl; file_create.close(); return 1; }
int file_open(LOG_CTX* ctx, const char* url) { const char* v; v = strstr(url, "@"); if(v) { char mode[20]; memcpy(&mode, url, v-url); mode[v-url] = '\0'; if(strcmp(mode, "single")==0) { ctx->file->mode = FILE_MODE_SINGLE; } else if(strcmp(mode, "once")==0) { ctx->file->mode = FILE_MODE_ONCE; } else if(strcmp(mode, "day")==0) { ctx->file->mode = FILE_MODE_EVERYDAY; } else if(strcmp(mode, "week")==0) { ctx->file->mode = FILE_MODE_EVERYWEEK; } else if(strcmp(mode, "mouth")==0) { ctx->file->mode = FILE_MODE_EVERYMOUTH; } else { return ERR_INVALID_PARAMETER; } url = v+1; } else { ctx->file->mode = FILE_MODE_SINGLE; } v = strrchr(url, '/'); if(v==NULL) v = strrchr(url, '\\'); if(v==NULL) v = url; else v++; strcpy(ctx->file->name, v); memset(ctx->file->path, 0, sizeof(ctx->file->path)); memcpy(ctx->file->path, url, v-url); if(!os_isdir(ctx->file->path) && os_mkdir(ctx->file->path)!=0) return ERR_UNKNOWN; ctx->file->mode = FILE_MODE_SINGLE; ctx->file->fp = file_create(ctx->file); if(ctx->file->fp==NULL) return ERR_FDOPEN; return ERR_NOERROR; }
int file_write(LOG_CTX* ctx, int level, const char* msg, unsigned int len) { time_t curtime; curtime = time(NULL); if(ctx->file->fp==NULL || (ctx->file->covertime>0 && ctx->file->covertime < curtime)) { if(ctx->file->fp) fclose(ctx->file->fp); ctx->file->fp = NULL; ctx->file->fp = file_create(ctx->file); if(ctx->file->fp==NULL) return ERR_FDOPEN; } fputs(msg, ctx->file->fp); fputs("\n", ctx->file->fp); return ERR_NOERROR; }