static void ls_close_log( ChannelLog *cl ) { if( cl->logfile ) os_fclose( cl->logfile ); cl->logfile = NULL; cl->ts_open = 0; }
void HTMLOutput( void ) { #define HTMLREADBUFSIZE 512 static char buf[HTMLREADBUFSIZE]; FILE *tpl; char *buftemp; char *bufptr; htmlfunc* htmlfuncptr; tpl = os_fopen( html_template, "rt" ); if( !tpl ) { nlog( LOG_WARNING, "Failed to open StatServ HTML template %s.", html_template ); irc_chanalert( statbot, "Failed to open StatServ HTML template %s.", html_template ); return; } opf = os_fopen( StatServ.htmlpath, "wt" ); if( !opf ) { nlog( LOG_WARNING, "Failed to open HTML output file %s. Check file permissions.", StatServ.htmlpath ); irc_chanalert( statbot, "Failed to open HTML output file %s. Check file permissions.", StatServ.htmlpath ); return; } while( os_fgets( buf, HTMLREADBUFSIZE, tpl ) != NULL ) { bufptr = buf; htmlfuncptr = htmlfuncs; while( htmlfuncptr->directive != NULL ) { buftemp = strstr( bufptr, htmlfuncptr->directive ); if( buftemp ) { os_fwrite( bufptr, ( int )buftemp -( int )bufptr, 1, opf ); htmlfuncptr->handler(); bufptr = buftemp + strlen( htmlfuncptr->directive ); } htmlfuncptr++; } os_fputs( bufptr, opf ); } os_fclose( tpl ); os_fclose( opf ); /* update the umode so others can read it and owner can overwrite it */ os_chmod( StatServ.htmlpath, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); }
static int ss_set_htmlpath_cb( const CmdParams *cmdparams, SET_REASON reason ) { FILE *opf; if( reason == SET_CHANGE ) { opf = os_fopen( StatServ.htmlpath, "wt" ); if( !opf ) { irc_prefmsg( statbot, cmdparams->source, "Failed to open HTML output file %s. Check file permissions. HTML output disabled.", StatServ.htmlpath ); return NS_SUCCESS; } os_fclose( opf ); HTMLOutput(); } return NS_SUCCESS; }
/*! *@brief 关闭存放运行时状态的文件 *@author zhaohm3 *@retval *@note * *@since 2014-9-25 16:33 *@attention * */ GPublic void file_close_fstat() { os_fflush(gpStatFile); os_fclose(gpStatFile); gpStatFile = NULL; }
/*! *@brief 关闭存放诊断结果的文件 *@author zhaohm3 *@retval *@note * *@since 2014-9-25 16:33 *@attention * */ GPublic void file_close_fresult() { os_fflush(gpResultFile); os_fclose(gpResultFile); gpResultFile = NULL; }
/*! *@brief 关闭存放调试信息的文件 *@author zhaohm3 *@retval *@note * *@since 2014-9-25 16:30 *@attention * */ GPublic void file_close_fdebug() { os_fflush(gpDebugFile); os_fclose(gpDebugFile); gpDebugFile = NULL; }
/* Return '0' if success */ S32 init_driver( PS8 adapter_name, PS8 eeprom_file_name, PS8 init_file_name, PS8 firmware_file_name ) { PVOID f1 = NULL, f2 = NULL, f3 = NULL; S32 eeprom_image_length = 0; S32 init_file_length = 0; S32 firmware_image_length = 0; U32 req_size = 0; TLoaderFilesData *init_info = NULL; S32 rc = -1; THandle hIpcSta; if( !adapter_name || !*adapter_name ) return rc; os_error_printf(CU_MSG_INFO1, (PS8)"+---------------------------+\n"); os_error_printf(CU_MSG_INFO1, (PS8)"| wlan_loader: initializing |\n"); os_error_printf(CU_MSG_INFO1, (PS8)"+---------------------------+\n"); hIpcSta = IpcSta_Create(adapter_name); if (hIpcSta == NULL) { os_error_printf (CU_MSG_ERROR, (PS8)"wlan_loader: cant allocate IpcSta context\n", eeprom_file_name); goto init_driver_end; } /* Send init request to the driver */ if ( (NULL != eeprom_file_name) && (f1 = os_fopen (eeprom_file_name, OS_FOPEN_READ)) != NULL) { eeprom_image_length = os_getFileSize(f1); if (-1 == eeprom_image_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get eeprom image file length <%s>\n", eeprom_file_name); goto init_driver_end; } } if ( (NULL != firmware_file_name) && (f2 = os_fopen (firmware_file_name, OS_FOPEN_READ)) != NULL) { firmware_image_length = os_getFileSize(f2); if (-1 == firmware_image_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get firmware image file length <%s>\n", firmware_file_name); goto init_driver_end; } } if ( (NULL != init_file_name) && (f3 = os_fopen (init_file_name, OS_FOPEN_READ)) != NULL) { init_file_length = os_getFileSize(f3); if (-1 == init_file_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get init file length <%s>\n", init_file_name); goto init_driver_end; } } /* Now when we can calculate the request length. allocate it and read the files */ req_size = sizeof(TLoaderFilesData) + eeprom_image_length + (init_file_length+1) + firmware_image_length; init_info = (TLoaderFilesData *)os_MemoryAlloc(req_size); if (!init_info) { os_error_printf(CU_MSG_ERROR, (PS8)"No memory to allocate init request (%d bytes)\n", req_size); goto init_driver_end; } init_info->uNvsFileLength = eeprom_image_length; init_info->uFwFileLength = firmware_image_length; init_info->uIniFileLength = init_file_length; if (!f1 || (eeprom_image_length && os_fread(&init_info->data[0], 1, eeprom_image_length, f1)<eeprom_image_length)) { } else os_error_printf(CU_MSG_INFO1, (PS8)"**** nvs file found %s **** \n", eeprom_file_name); if (!f2 || (firmware_image_length && os_fread(&init_info->data[eeprom_image_length], 1, firmware_image_length, f2)<firmware_image_length)) { os_error_printf(CU_MSG_ERROR, (PS8)"Error reading firmware image %s - Aborting...\n", firmware_file_name); goto init_driver_end; } if (!f3 || (init_file_length && os_fread(&init_info->data[eeprom_image_length+firmware_image_length], 1, init_file_length, f3)<init_file_length)) { os_error_printf(CU_MSG_ERROR, (PS8)"Warning: Error in reading init_file %s - Using defaults\n", init_file_name); } /* Load driver defaults */ if(EOALERR_IPC_STA_ERROR_SENDING_WEXT == IPC_STA_Private_Send(hIpcSta, DRIVER_INIT_PARAM, init_info, req_size, NULL, 0)) { os_error_printf(CU_MSG_ERROR, (PS8)"Wlan_loader: Error sending init command (DRIVER_INIT_PARAM) to driver\n"); goto init_driver_end; } /* No Error Found */ rc = 0; init_driver_end: if (f1) os_fclose(f1); if (f2) os_fclose(f2); if (f3) os_fclose(f3); if (init_info) os_MemoryFree(init_info); if (hIpcSta) IpcSta_Destroy(hIpcSta); return rc; }