Esempio n. 1
0
 SfxOptions read_controls() {
   SfxOptions options;
   const SfxModules& sfx_modules = ArcAPI::sfx();
   unsigned sfx_id = get_list_pos(module_ctrl_id);
   if (sfx_id >= sfx_modules.size()) {
     FAIL_MSG(Far::get_msg(MSG_SFX_OPTIONS_DLG_WRONG_MODULE));
   }
   options.name = extract_file_name(sfx_modules[sfx_id].path);
   options.replace_icon = get_check(replace_icon_ctrl_id);
   if (options.replace_icon) {
     options.icon_path = get_text(icon_path_ctrl_id);
     if (!File::exists(options.icon_path)) {
       FAIL_MSG(Far::get_msg(MSG_SFX_OPTIONS_DLG_INVALID_ICON_PATH));
     }
   }
   else
     options.icon_path.clear();
   options.replace_version = get_check(replace_version_ctrl_id);
   if (options.replace_version) {
     options.ver_info.version = get_text(ver_info_version_ctrl_id);
     options.ver_info.comments = get_text(ver_info_comments_ctrl_id);
     options.ver_info.company_name = get_text(ver_info_company_name_ctrl_id);
     options.ver_info.file_description = get_text(ver_info_file_description_ctrl_id);
     options.ver_info.legal_copyright = get_text(ver_info_legal_copyright_ctrl_id);
     options.ver_info.product_name = get_text(ver_info_product_name_ctrl_id);
   }
   else {
     options.ver_info.version.clear();
     options.ver_info.comments.clear();
     options.ver_info.company_name.clear();
     options.ver_info.file_description.clear();
     options.ver_info.legal_copyright.clear();
     options.ver_info.product_name.clear();
   }
   bool install_config_enabled = sfx_modules[sfx_id].install_config();
   options.append_install_config = install_config_enabled && get_check(append_install_config_ctrl_id);
   if (options.append_install_config) {
     options.install_config.title = get_text(install_config_title_ctrl_id);
     options.install_config.begin_prompt = get_text(install_config_begin_prompt_ctrl_id);
     TriState value = get_check3(install_config_progress_ctrl_id);
     if (value == triUndef)
       options.install_config.progress.clear();
     else
       options.install_config.progress = value == triTrue ? L"yes" : L"no";
     options.install_config.run_program = get_text(install_config_run_program_ctrl_id);
     options.install_config.directory = get_text(install_config_directory_ctrl_id);
     options.install_config.execute_file = get_text(install_config_execute_file_ctrl_id);
     options.install_config.execute_parameters = get_text(install_config_execute_parameters_ctrl_id);
   }
   else {
     options.install_config.title.clear();
     options.install_config.begin_prompt.clear();
     options.install_config.progress.clear();
     options.install_config.run_program.clear();
     options.install_config.directory.clear();
     options.install_config.execute_file.clear();
     options.install_config.execute_parameters.clear();
   }
   return options;
 }
Esempio n. 2
0
/* respond fdo_virtual_responce(filename)or a file GET request */
int do_http_get(struct tcp_pcb *pcb, char *req, int rlen)
{
	int BUFSIZE = 1400;
	char filename[MAX_FILENAME];

	/* 	unsigned char buf[BUFSIZE];
	signed int fsize, hlen, n;
	int fd;
	char *fext;
	err_t err;

	/ * determine file name */
	extract_file_name(filename, req, rlen, MAX_FILENAME);

	if(filename[0]== 'a') //we have a virtual action so parse it
	{
		return do_virtual_responce(pcb,filename);
	}

	/* respond with 404 if not present * /
	if (mfs_exists_file(filename) != 1) { */
		xil_printf("requested file %s not found, returning 404\r\n", filename);
		do_404(pcb, req, rlen);
		return -1;
//	}

	return 0;
}
Esempio n. 3
0
// set current file on panel to file_path
bool panel_go_to_file(HANDLE h_panel, const wstring& file_path) {
  wstring dir = extract_file_path(file_path);
  FarPanelDirectory fpd;
  memzero(fpd);
  fpd.StructSize = sizeof(FarPanelDirectory);
  fpd.Name = dir.c_str();
  if (!g_far.PanelControl(h_panel, FCTL_SETPANELDIRECTORY, 0, &fpd))
    return false;
  PanelInfo panel_info = {sizeof(PanelInfo)};
  if (!g_far.PanelControl(h_panel, FCTL_GETPANELINFO, 0, &panel_info))
    return false;
  wstring file_name = upcase(extract_file_name(file_path));
  PanelRedrawInfo panel_ri = { 0 };
  Buffer<unsigned char> buf(0x1000);
  size_t i;
  for (i = 0; i < panel_info.ItemsNumber; i++) {
    get_panel_item(h_panel, FCTL_GETPANELITEM, i, buf);
    const PluginPanelItem* panel_item = reinterpret_cast<const PluginPanelItem*>(buf.data());
    if (file_name == upcase(panel_item->FileName)) {
      panel_ri.CurrentItem = i;
      break;
    }
  }
  if (i == panel_info.ItemsNumber)
    return false;
  if (!g_far.PanelControl(h_panel, FCTL_REDRAWPANEL, 0, &panel_ri))
    return false;
  return true;
}
Esempio n. 4
0
unsigned SfxModules::find_by_name(const wstring& name) const {
  for (const_iterator sfx_module = begin(); sfx_module != end(); sfx_module++) {
    if (upcase(extract_file_name(sfx_module->path)) == upcase(name))
      return distance(begin(), sfx_module);
  }
  return size();
}
Esempio n. 5
0
LIBUTILS_API char * UTILS_API extract_file_pathA(char * path)
{
	char * p;
	p=extract_file_name(path);
	*(p-1)=0;
	return path;
}
Esempio n. 6
0
void error_dlg(CustomError& e) {
  UnicodeString msg;
  msg.add(far_get_msg(MSG_PLUGIN_NAME)).add('\n');
  if (e.object().size() != 0) msg.add(fit_str(e.object(), get_msg_width())).add('\n');
  if (e.message().size() != 0) msg.add(word_wrap(e.message(), get_msg_width())).add('\n');
  msg.add_fmt(L"%S:%u v.%u.%u.%u.%u"PLUGIN_TYPE, &extract_file_name(oem_to_unicode(e.file)), e.line, g_version.major, g_version.minor, g_version.patch, g_version.revision);
  far_message(c_error_dialog_guid, msg, 0, FMSG_WARNING | FMSG_MB_OK);
}
Esempio n. 7
0
const SfxModuleInfo* find(const wstring& path) {
  unsigned i = 0;
  for (; i < ARRAYSIZE(c_known_sfx_modules) && upcase(extract_file_name(path)) != upcase(c_known_sfx_modules[i].module_name); i++);
  if (i < ARRAYSIZE(c_known_sfx_modules))
    return c_known_sfx_modules + i;
  else
    return nullptr;
}
/* accumulate MIME attachment filenames. The filenames are appended by commas */
int log_file_name(const uint8_t *start, int length, FILE_LogState *log_state, bool *disp_cont)
{
    uint8_t *alt_buf;
    int alt_size;
    uint16_t *alt_len;
    int ret=0;
    int cont =0;
    int log_avail = 0;


    if(!start || (length <= 0))
    {
        *disp_cont = false;
        return -1;
    }

    if(*disp_cont)
        cont = 1;

    ret = extract_file_name((const char **)(&start), length, disp_cont);

    if (ret == -1)
        return ret;

    length = ret;

    alt_buf = log_state->filenames;
    alt_size =  MAX_FILE;
    alt_len = &(log_state->file_logged);
    log_avail = alt_size - *alt_len;

    if(!alt_buf || (log_avail <= 0))
        return -1;


    if ( *alt_len > 0 && ((*alt_len + 1) < alt_size))
    {
        if(!cont)
        {
            alt_buf[*alt_len] = ',';
            *alt_len = *alt_len + 1;
        }
    }

    ret = SafeMemcpy(alt_buf + *alt_len, start, length, alt_buf, alt_buf + alt_size);

    if (ret != SAFEMEM_SUCCESS)
    {
        if(*alt_len != 0)
            *alt_len = *alt_len - 1;
        return -1;
    }

    log_state->file_current = *alt_len;
    *alt_len += length;

    return 0;
}
Esempio n. 9
0
void error_dlg(const wstring& title, const Error& e) {
  wostringstream st;
  st << title << L'\n';
  if (e.code != E_MESSAGE) {
    wstring sys_msg = get_system_message(e.code, get_lang_id());
    if (!sys_msg.empty())
      st << word_wrap(sys_msg, get_optimal_msg_width()) << L'\n';
  }
  for (list<wstring>::const_iterator msg = e.messages.begin(); msg != e.messages.end(); msg++) {
    st << word_wrap(*msg, get_optimal_msg_width()) << L'\n';
  }
  st << extract_file_name(widen(e.file)) << L':' << e.line;
  message(c_error_dialog_guid, st.str(), 0, FMSG_WARNING | FMSG_MB_OK);
}
Esempio n. 10
0
bool VerifyEDATHeaderWithKLicense(const fs::file& input, const std::string& input_file_name, const std::array<u8, 0x10>& custom_klic, std::string* contentID)
{
	// Setup NPD and EDAT/SDAT structs.
	NPD_HEADER NPD;
	EDAT_HEADER EDAT;

	// Read in the NPD and EDAT/SDAT headers.
	read_npd_edat_header(&input, NPD, EDAT);

	unsigned char npd_magic[4] = { 0x4E, 0x50, 0x44, 0x00 };  //NPD0
	if (memcmp(&NPD.magic, npd_magic, 4))
	{
		LOG_ERROR(LOADER, "EDAT: %s has invalid NPD header or already decrypted.", input_file_name);
		return false;
	}

	if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG)
	{
		LOG_ERROR(LOADER, "EDAT: SDATA file given to edat function");
		return false;
	}

	// Perform header validation (EDAT only).
	char real_file_name[MAX_PATH];
	extract_file_name(input_file_name.c_str(), real_file_name);
	if (!validate_npd_hashes(real_file_name, custom_klic.data(), &NPD, false))
	{
		// Ignore header validation in DEBUG data.
		if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG)
		{
			LOG_ERROR(LOADER, "EDAT: NPD hash validation failed!");
			return false;
		}
	}

    *contentID = std::string(reinterpret_cast<const char*>(NPD.content_id));
	return true;
}
/* respond for a file GET request */
int do_http_get(struct tcp_pcb *pcb, char *req, int rlen)
{
	int BUFSIZE = 1400;
	char filename[MAX_FILENAME];
	char buf[BUFSIZE];
	int fsize, hlen, n;
	int fd;
	char *fext;
	err_t err;

	/* determine file name */
	extract_file_name(filename, req, rlen, MAX_FILENAME);

	/* respond with 404 if not present */
	if (mfs_exists_file(filename) != 1) {
		xil_printf("requested file %s not found, returning 404\r\n", filename);
		do_404(pcb, req, rlen);
		return -1;
	}

	/* respond with correct file */

	/* debug statement on UART */
        xil_printf("http GET: %s\r\n", filename);

	/* get a pointer to file extension */
	fext = get_file_extension(filename);

	fd = mfs_file_open(filename, MFS_MODE_READ);

	/* obtain file size,
	 * note that lseek with offset 0, MFS_SEEK_END does not move file pointer */
	fsize = mfs_file_lseek(fd, 0, MFS_SEEK_END);

	/* write the http headers */
	hlen = generate_http_header(buf, fext, fsize);
	if ((err = tcp_write(pcb, buf, hlen, 1)) != ERR_OK) {
		xil_printf("error (%d) writing http header to socket\r\n", err);
		xil_printf("attempted to write #bytes = %d, tcp_sndbuf = %d\r\n", hlen, tcp_sndbuf(pcb));
		xil_printf("http header = %s\r\n", buf);
		return -1;
	}

	/* now write the file */
	while (fsize) {
		int sndbuf;
		sndbuf = tcp_sndbuf(pcb);

		if (sndbuf < BUFSIZE) {
			/* not enough space in sndbuf, so send remaining bytes when there is space */
			/* this is done by storing the fd in as part of the tcp_arg, so that the sent
			   callback handler knows to send data */
			http_arg *a = (http_arg *)pcb->callback_arg;
			a->fd = fd;
			a->fsize = fsize;
			return 0;
		}

		n = mfs_file_read(fd, buf, BUFSIZE);

		if ((err = tcp_write(pcb, buf, n, 1)) != ERR_OK) {
			xil_printf("error writing file (%s) to socket, remaining unwritten bytes = %d\r\n",
					filename, fsize - n);
			xil_printf("attempted to lwip_write %d bytes, tcp write error = %d\r\n", n, err);
			break;
		}

		fsize -= n;
	}

	mfs_file_close(fd);

	return 0;
}
Esempio n. 12
0
static int generate_floppy(int argc, char *argv[])
{
    /* Initialize the image */
    floppy = (u8 *)malloc(FLOPPY_SIZE);
    buffer = (u8 *)malloc(BUFFER_SIZE);
    
    char *save_to = argv[1];
    
    FILE *file;
    u32 file_size;
    u32 count;
    u8 file_name[12];
    
    u32 current_offset = 0;
    u32 current_sector = 0;
    u8 *current_file;
    
    u32 i, j;
    
    /* Calculate FAT count and file count */
    u32 file_count = argc - 3;
    u32 fat_count = 1;
    if (file_count > 31) {
        u32 file_count_for_slave_fat = file_count - 31;
        fat_count += file_count_for_slave_fat / 32;
        
        if (file_count_for_slave_fat % 32) {
            fat_count++;
        }
    }
    printf("\tFile Count: %d\n", file_count);
    printf("\tFAT Count: %d\n", fat_count);
    
    /* Boot File */
    printf("\tProcessing Boot File: %s ... ", argv[2]);
    
    file_size = 0;
    file = fopen(argv[2], "rb");
    if (0 == file) {
        printf("Failed!\n");
        return 1;
    }
    fseek(file, 0, 0);
    
    do {
        /* Read the file */
        count = fread(buffer, 1, BUFFER_SIZE, file);
        
        /* Copy the file to floppy image */
        copy_to_floppy(buffer, current_offset, count);
        
        /* Set size and position */
        current_offset += count;
        file_size += count;
    } while (!feof(file));
    
    fclose(file);
    printf("Done!\n");
    
    /* Process FATs */
    current_sector = 16;
    current_offset = current_sector * 512;
    struct floppy_fat_master *fat_master = (struct floppy_fat_master *)((unsigned long)floppy + current_offset);
    fat_master->header.fat_count = fat_count;
    fat_master->header.file_count = file_count;
    
    /* Normal Files */
    current_sector = 16 + fat_count;
    current_offset = current_sector * 512;
    
    for (i = 0; i < file_count; i++) {
        current_file = argv[3 + i];
        printf("\tProcessing File: %s ... ", current_file);
        
        if (0 == current_file) {
            printf("Failed!\n");
            return -1;
        }
        
        /* Load the file */
        file_size = 0;
        file = fopen(current_file, "rb");
        if (0 == file) {
            printf("Failed!\n");
            return -1;
        }
        
        do {
            /* Read the file */
            count = fread(buffer, 1, BUFFER_SIZE, file);
            
            /* Copy the file to floppy image */
            copy_to_floppy(buffer, current_offset, count);
            
            /* Set size and position */
            current_offset += count;
            file_size += count;
        } while (!feof(file));
        
        fclose(file);
        
        /* Calculate file info */
        u32 sector_count = file_size / 512;
        if (file_size % 512) {
            sector_count++;
        }
        
        /* Extract file name */
        file_name[12];
        extract_file_name(file_name, current_file);
        
        /* Set file info in FAT */
        if (i < 31) {
            fat_master->entries[i].start_sector = current_sector;
            fat_master->entries[i].sector_count = sector_count;
            
            for (j = 0; j < 12; j++) {
                fat_master->entries[i].file_name[j] = file_name[j];
            }
        } else {
            u32 slave_index = (i - 31) / 32;
            u32 slave_i = i - 31 - 32 * slave_index;
            struct floppy_fat_slave *fat_slave = (struct floppy_fat_slave *)((unsigned long)fat_master + 512 * slave_index);
            
            fat_slave->entries[slave_i].start_sector = current_sector;
            fat_slave->entries[slave_i].sector_count = sector_count;
            
            for (j = 0; j < 12; j++) {
                fat_slave->entries[i].file_name[j] = file_name[j];
            }
        }
        
        /* Update our position */
        current_sector += sector_count;
        current_offset = current_offset = current_sector * 512;
        
        printf("Done!\n");
    }
    
    /* Save the floppy image */
    printf("\tWriting to image: %s ... ", argv[1]);
    
    file = fopen(argv[1], "wb");
    if (0 == file) {
        printf("Failed!\n");
        return 1;
    }
    
    fwrite(floppy, FLOPPY_SIZE, 1, file);
    
    fclose(file);
    printf("Done!\n");
    
    return 0;
}
Esempio n. 13
0
 wstring arc_name() const {
   wstring name = extract_file_name(arc_path);
   return name.empty() ? arc_path : name;
 }
Esempio n. 14
0
bool extract_all_data(const fs::file* input, const fs::file* output, const char* input_file_name, unsigned char* devklic, unsigned char* rifkey, bool verbose)
{
	// Setup NPD and EDAT/SDAT structs.
	NPD_HEADER NPD;
	EDAT_HEADER EDAT;

	// Read in the NPD and EDAT/SDAT headers.
	read_npd_edat_header(input, NPD, EDAT);

	unsigned char npd_magic[4] = {0x4E, 0x50, 0x44, 0x00};  //NPD0
	if (memcmp(&NPD.magic, npd_magic, 4))
	{
		LOG_ERROR(LOADER, "EDAT: %s has invalid NPD header or already decrypted.", input_file_name);
		return 1;
	}

	if (verbose)
	{
		LOG_NOTICE(LOADER, "NPD HEADER");
		LOG_NOTICE(LOADER, "NPD version: %d", NPD.version);
		LOG_NOTICE(LOADER, "NPD license: %d", NPD.license);
		LOG_NOTICE(LOADER, "NPD type: %d", NPD.type);
	}

	// Set decryption key.
	u8 key[0x10] = { 0 };

	// Check EDAT/SDAT flag.
	if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG)
	{
		if (verbose)
		{
			LOG_NOTICE(LOADER, "SDAT HEADER");
			LOG_NOTICE(LOADER, "SDAT flags: 0x%08X", EDAT.flags);
			LOG_NOTICE(LOADER, "SDAT block size: 0x%08X", EDAT.block_size);
			LOG_NOTICE(LOADER, "SDAT file size: 0x%08X", (u64)EDAT.file_size);
		}

		// Generate SDAT key.
		xor_key(key, NPD.dev_hash, SDAT_KEY);
	}
	else
	{
		if (verbose)
		{
			LOG_NOTICE(LOADER, "EDAT HEADER");
			LOG_NOTICE(LOADER, "EDAT flags: 0x%08X", EDAT.flags);
			LOG_NOTICE(LOADER, "EDAT block size: 0x%08X", EDAT.block_size);
			LOG_NOTICE(LOADER, "EDAT file size: 0x%08X", (u64)EDAT.file_size);
		}

		// Perform header validation (EDAT only).
		char real_file_name[MAX_PATH];
		extract_file_name(input_file_name, real_file_name);
		if (!validate_npd_hashes(real_file_name, devklic, &NPD, verbose))
		{
			// Ignore header validation in DEBUG data.
			if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG)
			{
				LOG_ERROR(LOADER, "EDAT: NPD hash validation failed!");
				return 1;
			}
		}

		// Select EDAT key.
		if ((NPD.license & 0x3) == 0x3)           // Type 3: Use supplied devklic.
			memcpy(key, devklic, 0x10);
		else if ((NPD.license & 0x2) == 0x2)      // Type 2: Use key from RAP file (RIF key).
		{
			memcpy(key, rifkey, 0x10);

			// Make sure we don't have an empty RIF key.
			int i, test = 0;
			for (i = 0; i < 0x10; i++)
			{
				if (key[i] != 0)
				{
					test = 1;
					break;
				}
			}

			if (!test)
			{
				LOG_ERROR(LOADER, "EDAT: A valid RAP file is needed for this EDAT file!");
				return 1;
			}
		}
		else if ((NPD.license & 0x1) == 0x1)      // Type 1: Use network activation.
		{
			LOG_ERROR(LOADER, "EDAT: Network license not supported!");
			return 1;
		}

		if (verbose)
		{
			int i;
			LOG_NOTICE(LOADER, "DEVKLIC: ");
			for (i = 0; i < 0x10; i++)
				LOG_NOTICE(LOADER, "%02X", devklic[i]);

			LOG_NOTICE(LOADER, "RIF KEY: ");
			for (i = 0; i < 0x10; i++)
				LOG_NOTICE(LOADER, "%02X", rifkey[i]);
		}
	}

	if (verbose)
	{
		int i;
		LOG_NOTICE(LOADER, "DECRYPTION KEY: ");
		for (i = 0; i < 0x10; i++)
			LOG_NOTICE(LOADER, "%02X", key[i]);
	}

	input->seek(0);
	if (check_data(key, &EDAT, &NPD, input, verbose))
	{
		LOG_ERROR(LOADER, "EDAT: Data parsing failed!");
		return 1;
	}

	input->seek(0);
	if (decrypt_data(input, output, &EDAT, &NPD, key, verbose))
	{
		LOG_ERROR(LOADER, "EDAT: Data decryption failed!");
		return 1;
	}

	return 0;
}
Esempio n. 15
0
int main(int argc, char const **argv)
{
	ios_base::sync_with_stdio(false);
	if(argc<2)
	{
		cout << "Usage: CppToHTML [options] <file>" << endl;
		return 0;
	}
	string file_name;
	for(int i=1; i<argc; ++i)
	{
		if(argv[i][0]=='-' && argv[i][1]=='c')
		{
			string col_scheme(argv[i]+2);
			if(col_scheme.empty() && ++i<argc) col_scheme.assign(argv[i]);
			if(col_scheme=="sublime") color_scheme=sublime;
			else if(col_scheme=="codeblocks") color_scheme=codeblocks;
			else cout << "Undefined color scheme!\nColor schemes:\n    sublime\n    codeblocks" << endl;
		}
		else if(string(argv[i])=="--help")
			cout << "Usage: CppToHTML [options] <file>\nOptions:\n    -c <color_scheme>   Color schemes: sublime, codeblocks" << endl;
		else file_name=argv[i];
	}
	if(file_name.empty())
	{
		cout << "You must specify the file name!\nUsage: CppToHTML [options] <file>" << endl;
		return 0;
	}
	// make is_name array
	is_true_name[static_cast<unsigned char>('_')]=is_name[static_cast<unsigned char>('_')]=true;
	for(int i='A'; i<='Z'; ++i)
		is_true_name[i]=is_name[i]=true;
	for(int i='a'; i<='z'; ++i)
		is_true_name[i]=is_name[i]=true;
	for(int i='0'; i<='9'; ++i)
		is_true_name[i]=true;
	// get search includes directories and actual path - only for linux!
	// includes
	fstream settings("settings.cfg", ios_base::in);
	if(settings.good())
	{
		string path;
		while(!settings.eof())
		{
			getline(settings, path);
			parser::include_directories.push_back(path);
		}
	}
	else cerr << "Cannot load settings.cfg file with include directories!\n";
	// path
	if(file_name[0]!='/')
	{
		system("pwd > lol.shell");
		fstream lol("lol.shell", ios_base::in);
		string path;
		if(lol.good())
		{
			getline(lol, path);
			lol.close();
		}
		system("rm -f lol.shell");
		if(*--path.end()!='/') path+='/';
		file_name=path+file_name;
	}
	parser::init();
	parser::parse_file(file_name);
	// ------------------
	fstream file(file_name.c_str(), ios_base::in), output;
	if(!file.good()) cerr << "Cannot open file!" << endl;
	else
	{
		output.open((file_name+".html").c_str(), ios_base::out);
		string input, lol, efn=extract_file_name(file_name);
		int i=2;
		switch(color_scheme)
		{
			case sublime: output << "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Source code of "+efn+"</title>\n<style>\nbody{\n  background: #272822;\n  color: #f8f8f2;\n  font-size: 14px;\n}\n.code_table{\n  border-spacing: 0;\n  display: inline-block;\n  line-height: 18px;\n  border: 2px solid #49483e;\n  border-radius: 4px;\n}\n.code_table pre{\nfont-family: \"DejaVu Sans Mono\"\n}\n.code_table tbody tr td{\n  padding: 0;\n}\n.cpp_code{\n  text-align: left;\n  margin: 0;\n  padding: 5px 5px 5px 1em;\n}\n\n.num_lines{\n  color: #8f908a;\n  margin: 0;\n  text-align: right;\n  padding: 5px 4px 5px 4px;\n  border-right: 2px solid #49483e;\n}\n.p1{color: #a6e22e;}\n.p2{color: #ff9b4b;}\n.p3{color: #f92672;}\n.p4{color: #66d9ef;font-style: italic;}\n.p41{color: #66d9ef;}\n.p42{color: #a6e22e;}\n.p5{color: #b15555;}\n.p6{color: #ae81ff;}\n.p7{color: #e6db74;}\n.p71{color: #e6db74;}\n.p8{color: #75715e;}\n.p9{color: #3c74ec;}\n</style>\n</head>\n<body>\n<table class=\"code_table\">\n<tbody>\n<tr>\n<td>\n<pre class=\"num_lines\">\n";break;
			case codeblocks: output << "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Source code of "+efn+"</title>\n<style>\nbody{\n  background: #ffffff;\n  color: #000000;\n  font-size: 14px;\n}\n.code_table{\n  border-spacing: 0;\n  display: inline-block;\n  line-height: 18px;\n  border: 1px solid #afafaf;\n  border-radius: 4px;\n}\n.code_table pre{\nfont-family: \"DejaVu Sans Mono\"\n}\n.code_table tbody tr td{\n  padding: 0;\n}\n.cpp_code{\n  text-align: left;\n  margin: 0;\n  padding: 5px 5px 5px 1em;\n}\n.num_lines{\n  color: #4c4c4c;\n  margin: 0;\n  text-align: right;\n  padding: 5px 4px 5px 4px;\n  border-right: 1px solid #afafaf;\n}\n.p1{color: #00a000;}\n.p2{color: #e20deb;font-weight: bold;}\n.p3{color: #0000ff;font-weight: bold;}\n.p4{color: #0000ff;font-weight: bold;}\n.p41{color: #1c8ce5;font-weight: bold;}\n.p42{color: #e20deb;font-weight: bold;}\n.p5{color: #ff0000;}\n.p6{color: #f000f0;}\n.p7{color: #0000ff;}\n.p71{color: #e0a000;}\n.p8{color: #a0a0a0;}\n.p9{color: #00a000;font-weight: bold;}\n</style>\n</head>\n<body>\n<table class=\"code_table\">\n<tbody>\n<tr>\n<td>\n<pre class=\"num_lines\">\n";break;
		}
		if(!file.eof())
		{
			getline(file, lol);
			// input+=lol (tab_size=4)
			for(int ll=lol.size(), q=0; q<ll; ++q)
			{
				if(lol[q]=='\t') input+="    ";
				else input+=lol[q];
			}
			output << '1' << endl;
		}
		while(!file.eof())
		{
			input+='\n';
			getline(file, lol);
			// input+=lol (tab_size=4)
			for(int ll=lol.size(), q=0; q<ll; ++q)
			{
				if(lol[q]=='\t') input+="    "; // tab size: 4
				else input+=lol[q];
			}
			output << i << '\n';
			++i;
		}
		file.close();
		output << "</pre>\n</td>\n<td>\n<pre class=\"cpp_code\">\n";
		//cout << input << endl;
		output << synax_highlight::code_coloring(input) << endl;
		output << "</pre>\n</td>\n</tr>\n</tbody>\n</table>\n</body>\n</html>";
		output.close();
		compress(file_name+".html");
	}
return 0;
}
Esempio n. 16
0
wstring SfxModule::description() const {
  const SfxModuleInfo* info = find(path);
  return info ? Far::get_msg(info->descr_id) : Far::get_msg(MSG_SFX_DESCR_UNKNOWN) + L" [" + extract_file_name(path) + L"]";
}