consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Naloga_1", "Naloga_1\Naloga_1.vcxproj", "{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Debug|x64.ActiveCfg = Debug|x64
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Debug|x64.Build.0 = Debug|x64
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Debug|x86.ActiveCfg = Debug|Win32
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Debug|x86.Build.0 = Debug|Win32
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Release|x64.ActiveCfg = Release|x64
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Release|x64.Build.0 = Release|x64
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Release|x86.ActiveCfg = Release|Win32
{8F0E2AC0-2C94-48BC-BDEC-135E5A5E026D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B0CB3A3-1721-4DC2-B3A0-6232AACA0E3B}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,132 @@
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
std::vector<int> countSort(std::vector<int> A)
{
std::vector<int> B;
std::vector<unsigned int> C;
int min = *std::min_element(A.begin(), A.end());
if (min < 0) {
for (auto i = A.begin(); i != A.end(); i++) {
*i -= min;
}
}
int max = *std::max_element(A.begin(), A.end());
C.assign(max + 1, 0);
for (int i : A) {
C[i]++;
}
for (int i = 1; i < C.size(); i++)
{
C[i] = C[i] + C[i - 1];
}
B.assign(A.size(), 0);
for (int i = A.size() - 1; i >= 0; i--)
{
B[C[A[i]] - 1] = A[i];
C[A[i]] = C[A[i]] - 1;
}
if (min < 0) {
for (auto i = B.begin(); i != B.end(); i++) {
*i += min;
}
}
return B;
}
std::vector<int> romanSort(std::vector<int> A)
{
std::vector<int> B;
std::vector<unsigned int> C;
int min = *std::min_element(A.begin(), A.end());
if (min < 0) {
for (auto i = A.begin(); i != A.end(); i++) {
*i -= min;
}
}
int max = *std::max_element(A.begin(), A.end());
C.assign(max + 1, 0);
for (int i : A) {
C[i]++;
}
for (int i = 0; i < C.size(); i++) {
for (int j = 0; j < C[i]; j++) {
B.emplace_back(i);
}
}
if (min < 0) {
for (auto i = B.begin(); i != B.end(); i++) {
*i += min;
}
}
return B;
}
int main(int argc, char** argv)
{
if (argc < 3) {
std::cout << "Ni dovolj argumentov\n";
return -1;
}
std::vector<int> A;
std::ifstream isteram(argv[2]);
if (isteram.is_open()) {
std::copy(std::istream_iterator<int>(isteram), std::istream_iterator<int>(), std::back_inserter(A));
isteram.close();
}
else {
std::cout << "Ni mogoce odpreti datoteke";
return -1;
}
std::vector<int> B;
if (atoi(argv[1]) == 0)
{
B = countSort(A);
}
else
{
B = romanSort(A);
}
std::ofstream osteram("out.txt");
if (osteram.is_open()) {
for (int i : B) {
osteram << i << " ";
}
}
else {
std::cout << "Ni mogoce odpreti datoteke";
return -1;
}
return 0;
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{8f0e2ac0-2c94-48bc-bdec-135e5a5e026d}</ProjectGuid>
<RootNamespace>Naloga1</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Naloga_1.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Naloga_1.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Naloga_2", "Naloga_2\Naloga_2.vcxproj", "{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Debug|x64.ActiveCfg = Debug|x64
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Debug|x64.Build.0 = Debug|x64
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Debug|x86.ActiveCfg = Debug|Win32
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Debug|x86.Build.0 = Debug|Win32
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Release|x64.ActiveCfg = Release|x64
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Release|x64.Build.0 = Release|x64
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Release|x86.ActiveCfg = Release|Win32
{574F0C45-1CDF-46EE-B4D3-BA99F0520DC5}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B4C22FB-1DA4-4B7F-88D6-7AE9091216ED}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,76 @@
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
int main(int argc, char** argv)
{
if (argc != 2)
{
std::cout << "Ni dovolj argumentov\n";
return -1;
}
std::vector<unsigned char> A;
std::ifstream isteram(argv[1]);
if (isteram.is_open()) {
std::copy(std::istream_iterator<int>(isteram), std::istream_iterator<int>(), std::back_inserter(A));
isteram.close();
}
else {
std::cout << "Ni mogoce odpreti datoteke";
return -1;
}
std::vector<unsigned char> B(A.size());
std::vector<int> C(2, 0);
for (int k = 0; k < 8; k++)
{
for (int i = 0; i < A.size(); ++i)
{
C[(A[i] >> k) & 1]++;
}
C[1] += C[0];
for (int i = A.size() - 1; i >= 0; i--)
{
B[--C[(A[i] >> k) & 1]] = A[i];
}
C[0] = C[1] = 0;
A = B;
}
std::ofstream osteram("out.txt");
if (osteram.is_open()) {
for (int i : B) {
osteram << i << " ";
}
}
else {
std::cout << "Ni mogoce odpreti datoteke";
return -1;
}
return 0;
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{574f0c45-1cdf-46ee-b4d3-ba99f0520dc5}</ProjectGuid>
<RootNamespace>Naloga2</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Naloga_2.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Naloga_2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1 @@
1 1 1 1 1 1 2 2 3 3 4 4 4 4 5 5 5 5 5 5 6 7 7 8 8 8 9 9 9 9 10 10 10 11 11 11 11 11 11 12 12 12 12 13 13 13 13 13 13 14 14 14 14 14 15 15 15 15 15 16 16 16 16 17 17 17 18 18 18 19 19 19 19 19 19 19 20 20 20 20 21 21 21 21 21 21 22 22 22 22 22 23 23 23 24 24 24 24 24 25 25 25 25 26 26 26 26 26 27 27 27 27 27 27 27 27 28 28 28 28 28 28 28 29 29 30 30 30 31 31 31 31 31 32 32 32 32 32 33 33 33 33 33 34 34 34 34 34 35 35 35 35 36 36 36 36 36 36 36 36 36 36 37 38 38 38 39 39 39 39 39 40 40 41 42 42 43 43 43 43 43 43 43 43 43 44 44 44 44 44 45 46 46 46 46 46 46 47 47 47 47 47 47 47 48 48 48 48 49 50 50 50 50 50 51 51 51 51 52 52 52 53 53 53 53 54 54 55 55 55 56 56 56 56 56 57 57 57 57 57 58 58 58 58 58 59 59 59 59 59 60 60 60 60 60 60 60 61 61 61 61 61 61 62 62 62 62 62 63 63 63 63 63 63 64 64 64 65 65 65 66 66 66 67 67 67 67 68 68 68 68 68 68 69 69 69 69 70 70 70 70 70 71 71 71 71 71 72 72 74 75 75 75 75 77 77 78 78 79 80 80 80 81 82 82 82 83 83 83 83 83 83 84 84 84 85 85 85 85 85 85 85 86 86 87 87 87 87 87 88 88 88 88 89 89 90 90 90 90 90 90 91 91 91 91 91 91 92 92 92 92 92 93 93 93 93 93 93 93 93 93 94 94 94 95 95 95 95 95 95 95 95 96 96 96 96 97 97 98 98 98 99 99 99 99 100 100 100 100 101 101 101 101 101 101 101 101 102 102 102 103 104 104 104 104 104 104 105 105 105 106 106 106 107 107 107 107 107 107 107 108 108 108 109 109 110 110 110 110 110 110 110 111 111 111 111 112 112 112 113 113 113 114 114 114 115 115 115 116 116 116 116 116 116 117 117 117 117 118 118 118 118 119 119 119 119 119 120 120 120 121 121 121 122 122 122 122 122 123 123 124 124 124 124 124 125 125 126 126 126 127 127 127 128 128 128 128 129 129 129 129 130 130 130 131 131 131 131 132 132 132 132 133 133 133 133 133 134 134 135 135 136 136 136 136 136 137 137 138 139 139 139 139 139 140 140 141 142 142 142 143 143 144 145 145 145 145 145 145 146 146 146 147 147 147 148 148 148 149 149 149 149 149 150 150 150 151 151 151 151 152 152 153 153 153 153 154 154 155 155 155 155 155 156 156 156 157 157 157 158 159 159 159 160 160 160 160 161 161 161 161 161 162 162 162 162 163 163 163 163 163 164 164 164 164 165 165 165 165 165 165 166 166 166 166 166 166 166 166 167 167 167 167 168 168 168 168 169 169 169 169 169 170 170 170 170 171 171 171 172 172 172 173 173 173 173 174 174 174 174 174 175 175 175 176 176 176 177 177 178 178 178 178 178 179 179 179 179 179 179 179 180 180 180 180 180 181 181 182 182 182 182 182 182 182 183 183 183 183 183 183 183 183 184 184 184 184 184 184 184 185 185 185 185 185 186 186 186 186 187 187 187 187 188 188 188 189 189 190 190 190 190 190 191 191 191 191 191 192 192 192 193 194 194 194 194 194 194 195 195 195 196 196 196 197 197 197 197 197 197 198 198 198 198 198 199 199 199 199 200 200 200 200 201 201 201 202 202 203 203 203 203 203 203 204 204 204 204 204 204 205 205 205 205 205 205 206 206 207 207 207 207 208 208 208 208 209 209 209 209 209 209 210 210 210 210 210 211 211 211 212 212 212 213 213 214 214 214 215 215 215 215 215 216 216 216 216 216 216 216 216 217 217 217 217 217 218 218 218 219 220 220 220 221 221 221 221 222 222 222 222 223 223 223 223 224 224 224 224 224 224 225 225 225 225 226 226 227 228 229 230 230 230 231 232 232 232 232 232 232 232 233 233 233 233 233 234 234 234 234 234 234 234 235 235 235 235 236 236 236 237 237 237 237 238 239 239 239 239 240 240 240 240 240 241 241 241 241 242 242 243 243 243 243 244 244 244 244 244 244 245 245 245 245 245 246 248 248 249 249 249 249 249 250 250 250 250 251 251 251 251 251 252 252 252 252 253 253 253 254 254 255 255 255 255 255 255 255 255 255

View File

@@ -0,0 +1 @@
233 150 54 149 26 225 148 116 254 217 239 46 41 94 174 167 207 19 125 171 119 235 62 187 250 21 148 179 194 224 223 245 26 57 160 149 156 160 151 16 244 23 20 184 36 13 100 188 95 100 56 1 178 200 106 22 92 218 51 63 218 9 47 36 210 67 35 217 48 136 206 190 36 81 23 122 15 120 243 249 95 27 165 111 204 48 77 252 137 106 27 5 209 185 25 161 70 83 120 234 234 26 43 8 119 129 22 117 215 180 110 153 166 19 122 36 216 187 165 37 129 234 251 104 56 196 159 163 246 114 89 115 188 60 240 22 224 142 67 88 190 83 1 119 118 255 234 80 19 54 120 10 210 187 115 67 198 160 126 253 215 126 230 221 13 215 116 38 11 248 107 83 90 34 233 155 4 24 95 118 1 176 162 17 93 95 224 100 226 5 255 182 145 118 20 85 34 221 232 65 236 146 34 151 109 84 163 52 11 70 209 27 112 240 134 109 32 207 138 69 169 184 219 243 183 183 188 128 47 102 87 68 192 43 249 163 35 149 185 237 245 198 91 47 166 43 13 110 19 177 72 53 179 202 66 174 28 9 159 124 12 199 136 39 24 241 87 13 215 82 104 200 217 216 60 207 205 197 52 178 33 117 82 46 39 233 163 33 210 241 224 151 60 230 134 190 34 92 129 39 96 214 30 216 3 121 24 110 5 194 113 216 236 21 193 190 191 179 5 128 21 11 101 239 104 236 199 234 251 141 39 232 250 222 26 58 19 61 161 169 21 71 47 10 239 162 169 69 27 198 183 150 251 56 192 50 166 53 169 237 161 89 111 15 194 63 204 173 69 36 72 163 140 225 211 51 20 245 155 227 58 157 64 194 62 88 61 185 63 200 59 50 88 131 78 79 220 93 101 60 184 195 153 106 240 202 209 60 186 222 102 16 108 46 130 156 116 110 195 63 205 50 93 131 240 160 249 133 170 74 245 121 152 57 101 183 32 22 96 165 43 87 59 123 95 75 145 11 80 85 33 235 166 176 56 18 135 122 183 2 199 1 151 93 165 87 19 62 110 36 15 107 92 147 71 29 124 119 91 176 168 198 125 57 60 17 192 147 204 182 92 105 24 183 189 182 32 235 107 23 149 223 64 255 93 85 68 198 13 68 90 178 110 98 128 255 172 178 179 16 11 55 205 232 98 255 123 2 154 136 173 169 157 94 68 197 61 237 49 211 43 39 182 114 197 185 194 132 17 5 180 201 250 75 213 245 127 217 75 22 63 91 25 65 241 75 91 230 31 14 69 182 4 57 234 186 68 15 170 200 156 205 244 62 8 184 180 43 166 71 232 66 133 20 63 58 115 131 46 84 59 50 4 203 21 83 9 86 101 80 155 38 77 170 208 152 149 101 124 131 88 173 183 32 107 104 248 45 255 201 82 122 225 114 130 164 146 84 195 90 216 110 107 220 7 108 147 15 133 127 211 244 212 107 214 112 132 142 59 21 166 126 93 204 95 253 237 145 208 191 233 143 168 36 1 214 155 12 103 55 136 233 60 252 142 90 145 184 210 38 162 174 46 139 111 105 55 243 185 254 100 253 31 33 222 70 85 12 255 132 161 124 172 203 12 221 113 182 223 32 209 197 48 187 47 144 139 132 14 105 27 252 51 42 91 191 145 94 19 30 85 161 221 128 249 101 178 104 31 116 179 177 46 10 67 180 139 231 251 181 204 181 207 124 212 135 33 133 35 139 155 95 136 182 113 47 216 91 93 164 172 190 232 166 35 255 14 95 3 58 44 255 36 87 122 243 174 83 8 28 249 28 167 104 9 203 208 244 168 209 215 204 251 212 40 194 62 224 127 218 83 171 119 157 206 99 5 145 121 244 165 102 171 196 28 175 180 65 71 174 101 203 137 116 90 44 58 14 184 150 217 93 61 167 205 31 159 242 173 197 66 117 92 27 59 196 234 99 191 154 99 27 203 222 203 232 224 68 133 199 153 167 164 85 18 28 61 61 186 43 78 226 96 148 101 250 210 36 108 201 209 25 252 53 220 40 93 189 70 175 223 242 28 179 129 47 143 43 158 107 16 179 36 51 183 4 130 42 29 24 44 25 191 96 186 44 56 50 28 48 140 241 240 57 97 213 168 86 239 175 170 139 53 44 162 43 6 165 235 197 166 7 117 64 146 116 216 184 13 71 26 27 90 70 238 228 18 85 244 14 98 99 31 208 205 112 118 30 52 225 232 216 11 164 97 111 1 229 34 153

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Naloga_3", "Naloga_3\Naloga_3.vcxproj", "{ED37F093-9646-4442-A8BD-F426EEE0ECD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Debug|x64.ActiveCfg = Debug|x64
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Debug|x64.Build.0 = Debug|x64
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Debug|x86.ActiveCfg = Debug|Win32
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Debug|x86.Build.0 = Debug|Win32
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Release|x64.ActiveCfg = Release|x64
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Release|x64.Build.0 = Release|x64
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Release|x86.ActiveCfg = Release|Win32
{ED37F093-9646-4442-A8BD-F426EEE0ECD5}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5785BCE3-9CB0-44F5-9CD7-A76CF23759A5}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,110 @@
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
void KMP(std::string& input, std::string& pat)
{
int M = pat.length();
int N = input.length();
std::vector<int> KMPNext(M);
KMPNext[0] = -1;
KMPNext[1] = 0;
for (size_t i = 2; i < M; i++)
{
int rep = 0;
for (size_t j = 0; j < i-1; j++)
{
if (pat[i - 1] == pat[j]) rep++;
}
KMPNext[i] = rep;
}
int i = 0;
int j = 0;
std::ofstream ostream("out.txt");
while ( j + i < N)
{
if (pat[i] != input[i + j])
{
j += i - KMPNext[i];
i = 0;
}
else
{
i++;
}
if (i == M) {
ostream << std::to_string(j) << " ";
j += M;
i = 0;
}
}
ostream.close();
}
void Sunday(std::string& input, std::string& pat)
{
int M = pat.length();
int N = input.length();
std::vector<int> BCH(256, M + 1);
for (int i = 0; i < M; i++)
BCH[pat[i]] = M - i;
int i = 0;
int j = 0;
std::ofstream ostream("out.txt");
while (j + i < N && j + M < N)
{
if (pat[i] != input[i + j])
{
j += BCH[input[j+M]];
i = 0;
}
else
{
i++;
}
if (i == M) {
ostream << std::to_string(j) << " ";
j += M;
i = 0;
}
}
ostream.close();
}
int main(int argc, char** argv)
{
if (argc != 4)
{
std::cout << argv[0] << " <opcija> <iskani niz> <datoteka besedila>\n";
return -1;
}
std::ifstream istram(argv[3]);
std::string input((std::istreambuf_iterator<char>(istram)),
std::istreambuf_iterator<char>());
istram.close();
std::string pat(argv[2]);
if (atoi(argv[1]) == 0)
KMP(input, pat);
else
Sunday(input, pat);
return 0;
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{ed37f093-9646-4442-a8bd-f426eee0ecd5}</ProjectGuid>
<RootNamespace>Naloga3</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Naloga_3.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Naloga_3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1 @@
0 446 892 1341 1787 2234 2679 3124 3569 4018 4464 4913 5358 5803 6248 6693 7138 7583 8028 8473 8918 9363

View File

@@ -0,0 +1,19 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Naloga_4", "Naloga_4\Naloga_4.vcxproj", "{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Debug|x64.ActiveCfg = Debug|x64
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Debug|x64.Build.0 = Debug|x64
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Debug|x86.ActiveCfg = Debug|Win32
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Debug|x86.Build.0 = Debug|Win32
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Release|x64.ActiveCfg = Release|x64
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Release|x64.Build.0 = Release|x64
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Release|x86.ActiveCfg = Release|Win32
{4AB4235A-2D75-4AC6-A8FF-7AC23D131947}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1CD70E5-9812-44EE-A3B6-02C74F200F7C}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,29 @@
#pragma once
#include <iostream>
#include <fstream>
class BinReader {
public:
int k;
std::ifstream f;
char x = 0;
BinReader(const char* p) : k(0) {
f.open(p, std::ios::binary);
}
char readByte() {
f.read((char*)&x, 1);
return x;
}
bool readBit() {
if (k == 8) {
readByte();
k = 0;
}
bool b = (x >> k) & 1;
k++;
return b;
}
};

View File

@@ -0,0 +1,39 @@
#pragma once
#include <iostream>
#include <fstream>
class BitReader {
public:
int k = 0;
std::ifstream f;
char x = 0;
BitReader(const char* p) : k(8) {
f.open(p, std::ios::binary);
}
~BitReader() {
f.close();
}
int readInt() {
int ret;
f.read((char*)&ret, 4);
return ret;
}
char readByte() {
f.read((char*)&x, 1);
return x;
}
bool readBit() {
if (k == 8) {
readByte();
k = 0;
}
bool b = (x >> k) & 1;
k++;
return b;
}
};

View File

@@ -0,0 +1,39 @@
#pragma once
#include <iostream>
#include <fstream>
class BitWriter {
public:
int k;
std::ofstream f;
char x = 0;
BitWriter(const char* p) : k(0) {
f.open(p, std::ios::binary);
}
~BitWriter() {
if (k > 0) writeByte(x);
f.close();
}
void writeByte(uint8_t x) {
//f.write((char*)&x, 1);
f << x;
}
void writeInt(int y) {
f.write((char*)&y, 4);
}
void writeBit(bool b) {
if (k == 8) {
writeByte(x);
k = 0;
x = 0;
}
x ^= (-b ^ x) & (1 << k);
k++;
}
};

View File

@@ -0,0 +1,56 @@
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include "ShannonFano.h"
class codeNode {
public:
codeNode() {
}
std::shared_ptr<codeNode> left;
std::shared_ptr<codeNode> right;
std::shared_ptr<codeNode> getNextNode(bool bit) {
if (bit) return left;
else return right;
}
uint8_t c = 0;
};
int main(int argc, char** argv)
{
if (argc != 3) {
std::cout << argv[0] << " <c ali d> <binarna datoteka>\n";
return -1;
}
//$(SolutionDir)alice.txt
ShannonFano sf;
std::string ex = "";
if (argv[1][0] == 'c') {
sf.commpress(argv[2]);
ex = "out.bin";
}
else {
sf.decommpress(argv[2]);
ex = "out_d.bin";
}
std::ifstream in_file(argv[2], std::ios::binary);
in_file.seekg(0, std::ios::end);
int file_size = in_file.tellg();
std::ifstream ex_file(ex, std::ios::binary);
ex_file.seekg(0, std::ios::end);
int file_size2 = ex_file.tellg();
std::cout << "compressed: " << std::to_string((float)file_size2 / (float)file_size) << "\n";
}

View File

@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{4ab4235a-2d75-4ac6-a8ff-7ac23d131947}</ProjectGuid>
<RootNamespace>Naloga4</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Naloga_4.cpp" />
<ClCompile Include="ShannonFano.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BitReader.h" />
<ClInclude Include="BitWriter.h" />
<ClInclude Include="ShannonFano.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Naloga_4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ShannonFano.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BitWriter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BitReader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ShannonFano.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,146 @@
#include "ShannonFano.h"
#include <fstream>
#include <iostream>
#include <algorithm>
#include "BitWriter.h"
#include "BitReader.h"
ShannonFano::ShannonFano()
{
for (size_t i = 0; i < 256; i++)
{
frequencies.push_back(frequency(i));
keys.push_back(key(i));
}
}
void ShannonFano::generateCodes(std::vector<frequency>& frequencies, std::string prefix)
{
if (frequencies.size() == 1)
{
keys[frequencies[0].c].k = prefix;
return;
}
int halfSize = 0;
for (size_t i = 0; i < frequencies.size(); i++)
{
halfSize += frequencies[i].count;
}
halfSize /= 2;
std::vector<frequency> left;
std::vector<frequency> right;
int sum = 0;
for (frequency var : frequencies)
{
if (sum < halfSize) {
left.push_back(var);
sum += var.count;
}
else {
right.push_back(var);
}
}
generateCodes(left, prefix + "0");
generateCodes(right, prefix + "1");
return;
}
void ShannonFano::commpress(std::string infile)
{
std::ifstream istram(infile, std::ios::binary);
if (!istram.is_open()) return;
uint8_t c = istram.get();
while (istram.good()) {
frequencies[c].count++;
c = istram.get();
}
istram.close();
BitWriter writer(cof.c_str());
for (size_t i = 0; i < frequencies.size(); i++)
{
writer.writeInt(frequencies[i].count);
}
std::sort(frequencies.begin(), frequencies.end(), [](frequency& a, frequency& b) { return a.count > b.count; });
for (int i = frequencies.size() - 1; i > 0; i--) {
if (frequencies[i].count == 0) frequencies.pop_back();
}
generateCodes(frequencies, "");
istram.open(infile, std::ios::binary);
c = istram.get();
while (istram.good()) {
for (size_t i = 0; i < keys[c].k.size(); i++)
{
if (keys[c].k[i] == '0') writer.writeBit(false);
else writer.writeBit(true);
}
c = istram.get();
}
istram.close();
}
void ShannonFano::decommpress(std::string infile)
{
BitReader reader(infile.c_str());
for (size_t i = 0; i < frequencies.size(); i++)
{
frequencies[i].count = reader.readInt();
}
std::sort(frequencies.begin(), frequencies.end(), [](frequency& a, frequency& b) { return a.count > b.count; });
for (int i = frequencies.size() - 1; i > 0; i--) {
if (frequencies[i].count == 0) frequencies.pop_back();
}
generateCodes(frequencies, "");
int totalCount = 0;
for (frequency i : frequencies) {
totalCount += i.count;
}
for (size_t i = keys.size() - 1; i > 0; i--)
{
if (keys[i].k == "") keys.erase(keys.begin() + i);
}
int count = 0;
std::string bits = "";
BitWriter writer(dof.c_str());
while (count < totalCount)
{
bool bit = reader.readBit();
if (bit)
{
bits += "1";
}
else
{
bits += "0";
}
for (size_t i = 0; i < keys.size(); i++)
{
if (keys[i].k == bits) {
writer.writeByte(keys[i].c);
bits = "";
count++;
break;
}
}
}
}

View File

@@ -0,0 +1,44 @@
#pragma once
#include <vector>
#include <string>
class frequency {
public:
frequency(char ch) {
c = ch;
}
uint8_t c;
int count = 0;
};
class key {
public:
key(char ch) {
c = ch;
}
uint8_t c;
std::string k = "";
};
class ShannonFano
{
public:
ShannonFano();
void commpress(std::string infile);
void decommpress(std::string infile);
private:
std::vector<key> keys;
std::vector<frequency> frequencies;
std::string cof = "out.bin";
std::string dof = "out_d.bin";
void generateCodes(std::vector<frequency>& frequencies, std::string prefix);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Naloga_5", "Naloga_5\Naloga_5.vcxproj", "{4B361AE9-F795-49AC-9435-5094D1010CA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Debug|x64.ActiveCfg = Debug|x64
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Debug|x64.Build.0 = Debug|x64
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Debug|x86.ActiveCfg = Debug|Win32
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Debug|x86.Build.0 = Debug|Win32
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Release|x64.ActiveCfg = Release|x64
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Release|x64.Build.0 = Release|x64
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Release|x86.ActiveCfg = Release|Win32
{4B361AE9-F795-49AC-9435-5094D1010CA7}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E783AB48-F863-4045-88A2-2D0188DB315B}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,200 @@
#include <iostream>
#include <fstream>
#include <string>
#include <list>
#include <vector>
class Playfair {
public:
Playfair(std::string key) {
sbox.resize(16, std::vector<uint8_t>(16));
std::list<uint8_t> data;
for (size_t i = 0; i < 256; i++)
{
data.push_back(i);
}
for (int i = key.size() - 1; i >= 0; i--)
{
data.remove(key[i]);
data.push_front(key[i]);
}
for (size_t i = 0; i < 16; i++)
{
for (size_t j = 0; j < 16; j++)
{
sbox[i][j] = data.front();
data.pop_front();
}
}
}
void encrypt(uint8_t& x, uint8_t& y) {
int a = 0, b = 0, c = 0, d = 0;
for (size_t i = 0; i < 16; i++)
{
for (size_t j = 0; j < 16; j++)
{
if (sbox[i][j] == x)
{
a = i;
b = j;
}
if (sbox[i][j] == y)
{
c = i;
d = j;
}
}
}
if (a != c && b != d)
{
x = sbox[a][d];
y = sbox[c][b];
}
else if (a == c && b != d)
{
b = (b + 1) % 16;
d = (d + 1) % 16;
x = sbox[a][b];
y = sbox[c][d];
}
else if (a != c && b == d)
{
a = (a + 1) % 16;
c = (c + 1) % 16;
x = sbox[a][b];
y = sbox[c][d];
}
}
void decrypt(uint8_t& x, uint8_t& y) {
int a = 0, b = 0, c = 0, d = 0;
for (size_t i = 0; i < 16; i++)
{
for (size_t j = 0; j < 16; j++)
{
if (sbox[i][j] == x)
{
a = i;
b = j;
}
if (sbox[i][j] == y)
{
c = i;
d = j;
}
}
}
if (a != c && b != d)
{
x = sbox[a][d];
y = sbox[c][b];
}
else if (a == c && b != d)
{
b = (b - 1) % 16;
d = (d - 1) % 16;
x = sbox[a][b];
y = sbox[c][d];
}
else if (a != c && b == d)
{
a = (a - 1) % 16;
c = (c - 1) % 16;
x = sbox[a][b];
y = sbox[c][d];
}
}
private:
std::vector<std::vector<uint8_t>> sbox;
};
int main(int argc, char** argv)
{
if (argc != 4)
{
std::cout << "Napacno stevilo argumentov!\n";
return 1;
}
std::ifstream instream(argv[3], std::ios::in | std::ios::binary);
if (!instream)
{
std::cout << "Napaka pri odpiranju datoteke!\n";
return 1;
}
std::vector<uint8_t> data((std::istreambuf_iterator<char>(instream)), std::istreambuf_iterator<char>());
instream.close();
std::string key = argv[2];
Playfair pf(key);
std::string output;
bool encrypt = false;
std::string e = argv[1];
if (e == "e")
{
output = "out_e.txt";
encrypt = true;
}
else
{
output = "out_d.txt";
encrypt = false;
}
int i = 0;
if (encrypt)
{
while (i < data.size())
{
if (i + 1 == data.size())
data.push_back(3);
if (i + 1 < data.size() && data[i] == data[i + 1])
data.insert(data.begin() + i + 1, 0);
if (i + 1 < data.size()) pf.encrypt(data[i], data[i + 1]);
i += 2;
}
}
else
{
while (i < data.size())
{
if (i + 1 < data.size()) pf.decrypt(data[i], data[i + 1]);
i += 2;
}
for (size_t j = 0; j < data.size(); j++)
{
if (data[j] == 0 || data[j] == 3)
data.erase(data.begin() + j);
}
}
std::ofstream outstream(output, std::ios::out | std::ios::binary);
if (!outstream)
{
std::cout << "Napaka pri odpiranju datoteke!\n";
return 1;
}
outstream.write((char*)data.data(), data.size());
outstream.close();
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{4b361ae9-f795-49ac-9435-5094d1010ca7}</ProjectGuid>
<RootNamespace>Naloga5</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Naloga_5.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Naloga_5.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1 @@
nikolajeTukajBill123456

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Naloga_6", "Naloga_6\Naloga_6.vcxproj", "{DBA24F35-D8E1-4279-A02C-96931E7E8C01}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
C|x64 = C|x64
C|x86 = C|x86
D|x64 = D|x64
D|x86 = D|x86
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.C|x64.ActiveCfg = C|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.C|x64.Build.0 = C|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.C|x86.ActiveCfg = C|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.C|x86.Build.0 = C|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.D|x64.ActiveCfg = D|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.D|x64.Build.0 = D|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.D|x86.ActiveCfg = D|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.D|x86.Build.0 = D|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Debug|x64.ActiveCfg = Debug|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Debug|x64.Build.0 = Debug|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Debug|x86.ActiveCfg = Debug|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Debug|x86.Build.0 = Debug|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Release|x64.ActiveCfg = Release|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Release|x64.Build.0 = Release|x64
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Release|x86.ActiveCfg = Release|Win32
{DBA24F35-D8E1-4279-A02C-96931E7E8C01}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5DCEFCD0-14BC-4D74-B27A-35DECA9E3349}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,54 @@
#pragma once
#include <iostream>
#include <fstream>
class BitReader {
public:
int k = 8;
std::ifstream f;
char x = 0;
BitReader(const char* p) : k(8) {
f.open(p, std::ios::binary);
}
~BitReader() {
f.close();
}
bool readInt(int &ret) {
f.read((char*)&ret, 4);
return (f)? false:true;
}
bool readInt16(uint16_t& ret) {
f.read((char*)&ret, 2);
return (f)? true : false;
}
bool readByte(char &b) {
f.read((char*)&b, 1);
return (f) ? true : false;
}
bool readBit(bool &b) {
bool ret = true;
if (k == 8) {
ret = readByte(x);
k = 0;
}
b = (x >> k) & 1;
k++;
return ret;
}
bool readBits(unsigned int& ret, int n) {
ret = 0;
for (int i = 0; i < n; i++) {
bool b;
if (!readBit(b)) return false;
ret |= b << i;
}
return true;
}
};

View File

@@ -0,0 +1,50 @@
#pragma once
#include <iostream>
#include <fstream>
class BitWriter {
public:
int k = 0;
std::ofstream f;
char x = 0;
BitWriter(const char* p) : k(0) {
f.open(p, std::ios::binary);
}
~BitWriter() {
if (k > 0) writeByte(x);
f.close();
}
void writeByte(uint8_t x) {
//f.write((char*)&x, 1);
f << x;
}
void writeInt(unsigned int y) {
f.write((char*)&y, 4);
}
void writeInt16(unsigned int y) {
f.write((char*)&y, 2);
}
void writeBit(bool b) {
if (k == 8) {
writeByte(x);
k = 0;
x = 0;
}
x ^= (-b ^ x) & (1 << k);
k++;
}
void writeBits(unsigned int y, int n) {
for (int i = 0; i < n; i++) {
writeBit(y & 1);
y >>= 1;
}
}
};

View File

@@ -0,0 +1,135 @@
#include <iostream>
#include <string>
#include <unordered_map>
#include <fstream>
#include <cmath>
#include "BitWriter.h"
#include "BitReader.h"
void resetMap(std::unordered_map<std::string, int>& S)
{
S.clear();
for (int i = 0; i < 256; i++) S.insert(std::make_pair(std::string(1, i), i));
//for (int i = 0; i < 26; i++) S.insert(std::make_pair(std::string(1, i+97), i));
}
void resetMap(std::unordered_map<int, std::string>& S)
{
S.clear();
for (int i = 0; i < 256; i++) S.insert(std::make_pair(i, std::string(1, i)));
//for (int i = 0; i < 26; i++) S.insert(std::make_pair(i, std::string(1, i+97)));
}
void commpress(std::string filename, int size)
{
int bits = std::ceil(std::log2(size));
std::unordered_map<std::string, int> S;
resetMap(S);
std::string T = "";
std::ifstream file(filename, std::fstream::binary | std::fstream::in);
BitWriter ofile("out.bin");
if (!file.is_open()) return;
char c;
bool seen = false;
while (file.get(c))
{
std::string TC = T + c;
auto got = S.find(TC);
if (got != S.end())
{
T = TC;
seen = true;
}
else
{
ofile.writeBits(S[T], bits);
if (S.size() == size) resetMap(S);
S.insert(std::make_pair(TC, S.size()));
T = c;
seen = false;
}
}
if(seen) ofile.writeBits(S[T], bits);
file.close();
}
void decommpress(std::string filename, int size)
{
int bits = std::ceil(std::log2(size));
std::unordered_map<int, std::string> S;
resetMap(S);
BitReader ifile(filename.c_str());
std::ofstream file("out.bin", std::fstream::binary | std::fstream::out);
if (!file.is_open()) return;
std::string T = "";
unsigned int c;
while (ifile.readBits(c, bits))
{
auto got = S.find(c);
if (got != S.end())
{
file << got->second;
std::string tmp = got->second;
if (T.size() > 0)
{
if (S.size() == size)
resetMap(S);
S.insert(std::make_pair(S.size(), T + tmp[0]));
}
T = tmp;
}
else
{
file << T + T[0];
if (S.size() == size)
resetMap(S);
S.insert(std::make_pair(S.size(), T + T[0]));
}
}
file.close();
}
int main(int argc, char** argv)
{
// d 10 $(SolutionDir)commpressed.bin
if (argc != 4)
{
std::cout << "Napacno stevilo argumentov!\n";
return 1;
}
std::string mode = argv[1];
int n = std::stoi(argv[2]);
std::string input = argv[3];
if(mode == "c")
commpress(input, n);
else
decommpress(input, n);
}

View File

@@ -0,0 +1,239 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="C|Win32">
<Configuration>C</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="C|x64">
<Configuration>C</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="D|Win32">
<Configuration>D</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="D|x64">
<Configuration>D</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{dba24f35-d8e1-4279-a02c-96931e7e8c01}</ProjectGuid>
<RootNamespace>Naloga6</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='D|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='C|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='D|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='C|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='D|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='C|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='D|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='C|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='D|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='C|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='D|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='C|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Naloga_6.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BitReader.h" />
<ClInclude Include="BitWriter.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Naloga_6.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BitReader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BitWriter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,18 @@
all: build run
debug: buildd run clean
zip:
zip naloga.zip main.c Makefile podatki.c podatki.h
build: main.c podatki.c podatki.h
gcc -m32 -O3 main.c podatki.c -o demo_podatki
buildd: main.c podatki.c podatki.h
gcc -g -m32 main.c podatki.c -o demo_podatki -fsanitize=address -fno-omit-frame-pointer
run:
time ./demo_podatki
clean:
rm -f demo_podatki

View File

@@ -0,0 +1,11 @@
#include <stdlib.h>
#include <stdio.h>
#include "podatki.h"
int main(){
void* pomnilnik = rezerviraj(sizeof(uint16_t)*6);
vstavi(pomnilnik);
izpis(pomnilnik);
brisi(pomnilnik);
return 0;
}

View File

@@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include "podatki.h"
uint16_t* rezerviraj(int velikostZlogi){
uint16_t* ret = malloc(velikostZlogi);
for (size_t i = 0; i < velikostZlogi/sizeof(uint16_t); i++)
{
ret[i] = 26132;
}
return ret;
}
void brisi(uint16_t* pomnilnik){
free(pomnilnik);
}
uint16_t* vstavi(uint16_t* pomnilnik){
uint8_t* point = (uint8_t*)pomnilnik;
*(char*)point = 'X';
point++;
*(char*)point = 'P';
point++;
*(char*)point = 'O';
point++;
*(float*)point = (22.0/7.0);
point += 4;
*(uint32_t*)point = 26132;
point += 4;
*(char*)point = '!';
}
void izpis(uint16_t* pomnilnik){
uint8_t* point = (uint8_t*)pomnilnik;
printf("%c\n", *(char*)point);
point++;
printf("%c\n", *(char*)point);
point++;
printf("%c\n", *(char*)point);
point++;
printf("%f\n", *(float*)point);
point+=4;
printf("%d\n", *(uint32_t*)point);
point+=4;
printf("%c\n", *(char*)point);
}

View File

@@ -0,0 +1,14 @@
#ifndef PODATKI
#define PODATKI
#include <stdint.h>
uint16_t* rezerviraj(int velikostZlogi);
void brisi(uint16_t* pomnilnik);
uint16_t* vstavi(uint16_t* pomnilnik);
void izpis(uint16_t* pomnilnik);
#endif

View File

@@ -0,0 +1,18 @@
all: build run
debug: buildd run clean
zip:
zip naloga.zip main.c Makefile pretvori.c pretvori.h
build: main.c pretvori.c pretvori.h
gcc -m32 main.c pretvori.c -o demo_pretvori
buildd: main.c pretvori.c pretvori.h
gcc -g -m32 main.c pretvori.c -o demo_pretvori -fsanitize=address -fno-omit-frame-pointer
run:
./demo_pretvori 80
clean:
rm -f demo_pretvori

View File

@@ -0,0 +1,18 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "pretvori.h"
int main(int argc, char *argv[])
{
if(argc < 2) {
printf("Ni dovolj argumentov");
return -1;
}
int unicode = preberiVhod(argv);
int utf8 = pretvoriZnak(unicode);
izpisiZnak(utf8);
return 0;
}

View File

@@ -0,0 +1,90 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "pretvori.h"
int preberiVhod(char* cmd[])
{
unsigned int ret = 0;
int len = strlen(cmd[1]);
uint8_t hex = 0;
for (size_t i = 0; i < len; i++)
{
if(cmd[1][i] >= '0' && cmd[1][i] <= '9')
{
hex = cmd[1][i] - '0';
}
else if (cmd[1][i] >= 'A' && cmd[1][i] <= 'F')
{
hex = cmd[1][i] - 'A' + 10;
}
ret = ret << 4;
ret = ret | hex;
}
return ret;
}
int pretvoriZnak(int znak)
{
int ret = 0;
if(znak <= 0x7F)
{
return znak;
}
if(znak <= 0x7FF)
{
//110xxxxx10xxxxxx
ret = 0b1100000010000000;
uint32_t mask1 = 0b111111;
ret = ret | (znak & mask1);
uint32_t mask2 = 0b1111100000000;
ret = ret | ((znak << 2) & mask2);
return ret;
}
//if((znak >> 13) == 0b110)
if(znak <= 0xFFFF)
{
//1110xxxx10xxxxxx10xxxxxx
ret = 0b111000001000000010000000;
uint32_t mask1 = 0b111111;
ret = ret | (znak & mask1);
uint32_t mask2 = 0b11111100000000;
ret = ret | ((znak << 2) & mask2);
uint32_t mask3 = 0b11110000000000000000;
ret = ret | ((znak << 4) & mask3);
return ret;
}
return ret;
}
void izpisiZnak(int znak)
{
printf("UTF-8 binarno: ");
int firstZero = 0;
if ( znak <= 0xFF ) firstZero = 7;
else if (znak <= 0xFFFF ) firstZero = 15;
else if (znak <= 0xFFFFFF ) firstZero = 23;
for (int i = firstZero; i >= 0; i--)
{
// Z bitshiftanjem pogledam ali je na mestu 1 ce je dobim neko stevilo vecje od 1 in zapisem 1
int j = znak & (1 << i);
printf("%d", (j>0)?1:0);
if(i % 4 == 0) printf(" ");
}
printf("\nUTF-8 hex: %X", znak);
printf("\n");
}

View File

@@ -0,0 +1,8 @@
#ifndef PODATKI
#define PODATKI
int preberiVhod(char* cmd[]);
int pretvoriZnak(int znak);
void izpisiZnak(int znak);
#endif

View File

@@ -0,0 +1,21 @@
all: build run
debug: buildd run clean
zip:
zip naloga.zip main.c Makefile
build: main.c
gcc -m32 -O3 main.c -o demo_client
buildd: main.c
gcc -g -m32 main.c -o demo_client -fsanitize=address -fno-omit-frame-pointer
run:
./demo_client localhost 8003 test1
clean:
rm -f demo_client main
chm:
chmod 755 script.sh

View File

@@ -0,0 +1,241 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <dirent.h>
#define MAXDATASIZE 1024
#define DATOTEKA 2147483648
#define MAPA 1073741824
#define KONEC 0
typedef struct Data
{
uint32_t size;
uint32_t type;
char name[128];
} Data;
int isDir(const char *path)
{
struct stat path_stat;
stat(path, &path_stat);
return S_ISDIR(path_stat.st_mode);
}
void sendFile(int sockfd, const char *fileName)
{
struct stat st;
stat(fileName, &st);
Data dataS;
dataS.size = st.st_size;
dataS.type = DATOTEKA;
memset(dataS.name, '\0', sizeof(dataS.name));
strcpy(dataS.name, fileName);
if (send(sockfd, &dataS, sizeof(dataS), 0) < 0)
{
perror("send");
return;
}
FILE *ptr = fopen(fileName, "rb");
if (ptr == NULL)
{
perror("File");
return;
}
uint8_t buffer[MAXDATASIZE];
size_t bytesRead = 0;
while (bytesRead < st.st_size)
{
size_t read = fread(buffer, 1, sizeof(buffer), ptr);
if (send(sockfd, buffer, read, 0) < 0)
{
perror("send");
}
bytesRead += read;
}
fclose(ptr);
printf("USPEL\tZBIRKA\t%s\t%d\n", dataS.name, dataS.size);
}
void sendDir(int sockfd, const char *folderName)
{
Data dataToSend;
dataToSend.size = 0;
dataToSend.type = MAPA;
strcpy(dataToSend.name, folderName);
if (send(sockfd, &dataToSend, sizeof(dataToSend), 0) < 0)
{
perror("send");
return;
}
printf("USPEL\tIMENIK\t%s\t%d\n", dataToSend.name, dataToSend.size);
}
void reciveConferm(int sockfd)
{
uint8_t ret;
if ((recv(sockfd, &ret, sizeof(ret), 0)) == -1)
{
perror("recv");
}
}
void sendEnd(int sockfd)
{
Data dataToSend;
dataToSend.size = 0;
dataToSend.type = KONEC;
strcpy(dataToSend.name, "");
if (send(sockfd, &dataToSend, sizeof(dataToSend), 0) < 0)
{
perror("send");
return;
}
}
void sendFullFile(int sockfd, char *input)
{
//nik/nik/nik.txt
char *ptr = strtok(input, "/");
char fileName[128];
memset(fileName, '\0', sizeof(fileName));
while (ptr != NULL)
{
strcat(fileName, ptr);
if (isDir(fileName))
{
sendDir(sockfd, fileName);
strcat(fileName, "/");
}
else
{
sendFile(sockfd, fileName);
}
reciveConferm(sockfd);
ptr = strtok(NULL, "/");
}
}
void sendFullDir(int sockfd, char *input)
{
char fileName[128];
memset(fileName, '\0', sizeof(fileName));
//nik/test
char *ptr = strtok(input, "/");
while (ptr != NULL)
{
strcat(fileName, ptr);
if (isDir(fileName))
{
sendDir(sockfd, fileName);
strcat(fileName, "/");
}
reciveConferm(sockfd);
ptr = strtok(NULL, "/");
}
struct dirent *files;
DIR *dir = opendir(fileName);
if (dir == NULL)
{
printf("Directory cannot be opened!");
return;
}
//nik/test/nik.txt
char srcName[128];
while ((files = readdir(dir)) != NULL)
{
if(strncmp( "..", files->d_name, 2) > -1) continue;
if(strncmp( ".", files->d_name, 1) > -1) continue;
strcpy(srcName, fileName);
strcat(srcName, files->d_name);
if (!isDir(srcName))
{
sendFile(sockfd, srcName);
reciveConferm(sockfd);
}
else
{
sendFullDir(sockfd, srcName);
}
}
closedir(dir);
}
int main(int argc, char *argv[])
{
if (argc != 4)
{
//write(0, "Uporaba: TCPtimec ime vrata datoteka\n\0", 29);
printf("Uporaba: TCPtimec ime vrata datoteka\n");
exit(1);
}
int sockfd; // socekt file descriptor, new file descriptor
struct hostent *he; // pointer to the structure hostent (returned by gethostbyname)
struct sockaddr_in their_addr; // server address
// get the server IP address
if ((he = gethostbyname(argv[1])) == NULL)
{
herror("gethostbyname"); // prints string + value of h_error variable [HOST_NOT_FOUND || NO_ADDRESS or NO_DATA || NO_RECOVERY || TRY_AGAIN]
exit(1);
}
// create socket
if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
{
perror("socket");
exit(1);
}
their_addr.sin_family = AF_INET; // family to Address Family InterNET
their_addr.sin_port = htons(atoi(argv[2])); // get server's port number - should be checked for input errors (not a number, etc.)
their_addr.sin_addr = *((struct in_addr *)he->h_addr); // server's IP address from hostent structure pointed to by he variable...
memset(&(their_addr.sin_zero), '\0', 8); // for conversion between structures only, a trick to ensure pointer casting...
// connect to the server... (no bind necessary as we are connecting to remote host... Kernel will find a free port for us and will bind it to sockfd)
if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
{
perror("connect");
exit(1);
}
//nik
if (isDir(argv[3]))
{
sendFullDir(sockfd, argv[3]);
}
else
{
sendFullFile(sockfd, argv[3]);
}
sendEnd(sockfd);
// close socket
close(sockfd);
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -0,0 +1 @@
test2

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -0,0 +1,21 @@
all: build run
debug: buildd run clean
zip:
zip naloga.zip main.c Makefile
build: main.c
gcc -m32 -O3 main.c -o demo_streznik -pthread
buildd: main.c
gcc -g -m32 main.c -o demo_streznik -fsanitize=address -fno-omit-frame-pointer
run:
./demo_streznik 8003
clean:
rm -f demo_streznik
cleanAll:
rm -f img.jpg text.txt Video1.mp4 Video2.mp4

View File

@@ -0,0 +1,160 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <pthread.h>
#include <string.h>
#define MAXDATASIZE 1024
#define DATOTEKA 2
#define MAPA 1
#define KONEC 0
typedef struct Data
{
uint32_t sizeOfFile;
uint32_t type;
char fileName[128];
} Data;
void reciveFile(int newfd, Data data)
{
uint8_t buffer[MAXDATASIZE];
int numbytes = 0;
FILE *wptr = fopen(data.fileName, "wb");
size_t bytesRecived = 0;
while (bytesRecived < data.sizeOfFile)
{
if ((numbytes = recv(newfd, buffer, MAXDATASIZE, 0)) == -1)
{
perror("recv");
return;
}
fwrite(buffer, numbytes, 1, wptr);
bytesRecived += numbytes;
}
fclose(wptr);
}
void sendConf(int newfd)
{
uint8_t ret = 0;
if (send(newfd, &ret, sizeof(ret), 0) < 0)
{
perror("send1");
return;
}
}
void reciveFolder(Data data)
{
mkdir(data.fileName, 0777);
}
void *recive(void *fd)
{
int newfd = *(int *)fd;
int exit = 0;
while (1)
{
Data recivedData;
if ((recv(newfd, &recivedData, sizeof(recivedData), 0)) == -1)
{
perror("recv");
// exit(1);
}
switch (recivedData.type)
{
case DATOTEKA:
reciveFile(newfd, recivedData);
printf("USPEL\tZBIRKA\t%s\t%d\n", recivedData.fileName, recivedData.sizeOfFile);
break;
case MAPA:
reciveFolder(recivedData);
printf("USPEL\tIMENIK\t%s\t%d\n", recivedData.fileName, recivedData.sizeOfFile);
break;
case KONEC:
close(newfd);
exit = 1;
break;
default:
break;
}
if (exit)
break;
sendConf(newfd);
}
}
int main(int argc, char *argv[])
{
int sockfd; // socekt file descriptor, new file descriptor
socklen_t length; // socket length (length of clinet address)
struct sockaddr_in saddr, caddr; // server address, client address
time_t itime; // time format
char *tstr; // var holding the string to be send via TCP
if (argc != 2)
{
printf("Uporaba: demo_client vrata (vrata 0-1024 so rezervirana za jedro)\n");
exit(1);
}
// create socket
if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
{
perror("socket");
}
saddr.sin_family = AF_INET; // IPv4
saddr.sin_addr.s_addr = INADDR_ANY; // localhost
saddr.sin_port = htons(atoi(argv[1])); // port converted from ascii to integer
// binds the socket file description to the actual port (similar to open)
if (bind(sockfd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0)
{
perror("bind");
return 0;
}
// start listening on the given port
if (listen(sockfd, 0) < 0)
{
perror("listen");
return 0;
}
length = sizeof(caddr); // length of client address
pthread_t thread_id[10];
int newfd[10];
uint8_t kaz = 0;
while (1)
{
if ((newfd[kaz] = accept(sockfd, (struct sockaddr *)&caddr, &length)) < 0)
{
perror("accept");
return 0;
}
recive(newfd);
pthread_create(&thread_id[kaz], NULL, recive, &newfd[kaz]);
// recive(newfd[kaz]);
kaz++;
kaz = kaz % 10;
}
for (size_t i = 0; i < 10; i++)
{
pthread_join(thread_id[i], NULL);
}
close(sockfd);
return 0;
}

View File

@@ -0,0 +1,28 @@
all: build run
zip:
zip naloga.zip main.c Makefile
build: main.o
ld -m elf_i386 main.o \
/usr/lib32/crt1.o \
/usr/lib32/crti.o \
/usr/lib32/crtn.o \
-dynamic-linker \
/usr/lib32/ld-linux.so.2 \
-lc -o hello \
run: hello
./hello
clean:
rm -f hello main.i main.s main.o
build_i: main.c
cpp -m32 main.c -o main.i
build_s: main.i
gcc -S -m32 main.i -o main.s
build_o: main.s
as -32 main.s -o main.o

View File

@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}

View File

@@ -0,0 +1,23 @@
all: build run
debug: buildd run clean
zip:
zip naloga.zip hello.c Makefile fun.c fun.h main.c
build: build_hello build_elf_changer
build_hello: hello.c
gcc -m32 hello.c -o hello
buildd: main.c fun.c
gcc -g -m32 main.c fun.c -o elf_changer -fsanitize=address -fno-omit-frame-pointer -Wall -Wextra -Wpedantic -Werror
build_elf_changer:
gcc -m32 main.c fun.c -o elf_changer -Wall -Wextra -Wpedantic -Werror
run:
./elf_changer -h hello
clean:
rm -f hello elf_changer

View File

@@ -0,0 +1,299 @@
#include "fun.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void printElf(const char *fileName)
{
FILE *fp = fopen(fileName, "rb");
if (fp == NULL)
{
printf("Error: cannot open file\n");
return;
}
Elf32_Ehdr ehdr;
fread(&ehdr, sizeof(Elf32_Ehdr), 1, fp);
fclose(fp);
printf("ELF header:\n");
printf(" Magic number:\t\t\t\t\t\t%02x %02x %02x %02x\n", ehdr.e_ident[0], ehdr.e_ident[1], ehdr.e_ident[2], ehdr.e_ident[3]);
printf(" Class:\t\t\t\t\t\t");
switch (ehdr.e_ident[EI_CLASS])
{
case ELFCLASSNONE:
printf("Invalid class\n");
break;
case ELFCLASS32:
printf("ELF32\n");
break;
case ELFCLASS64:
printf("ELF64\n");
break;
default:
printf("Unknown class (0x%x)\n", ehdr.e_ident[4]);
break;
}
printf(" Data:\t\t\t\t\t\t\t");
switch (ehdr.e_ident[EI_DATA])
{
case ELFDATANONE:
printf("Invalid data encoding\n");
break;
case ELFDATA2LSB:
printf("2's complement, little endian\n");
break;
case ELFDATA2MSB:
printf("2's complement, big endian\n");
break;
default:
printf("Unknown data encoding (0x%x)\n", ehdr.e_ident[5]);
break;
}
printf(" Version:\t\t\t\t\t\t");
switch (ehdr.e_ident[EI_VERSION])
{
case EV_NONE:
printf("Invalid version\n");
break;
case EV_CURRENT:
printf("Current version\n");
break;
default:
printf("Unknown version (0x%x)\n", ehdr.e_ident[6]);
break;
}
printf(" OS/ABI:\t\t\t\t\t\t");
switch (ehdr.e_ident[EI_OSABI])
{
case ELFOSABI_NONE:
printf("UNIX System V ABI\n");
break;
default:
printf("Unknown OS/ABI (0x%x)\n", ehdr.e_ident[7]);
break;
}
printf(" ABI Version:\t\t\t\t\t\t%d\n", ehdr.e_ident[EI_ABIVERSION]);
printf(" Type:\t\t\t\t\t\t\t");
switch (ehdr.e_type)
{
case ET_NONE:
printf("No file type\n");
break;
case ET_REL:
printf("Relocatable file\n");
break;
case ET_EXEC:
printf("Executable file\n");
break;
case ET_DYN:
printf("Shared object file\n");
break;
case ET_CORE:
printf("Core file\n");
break;
case ET_LOPROC:
printf("Processor-specific\n");
break;
case ET_HIPROC:
printf("Processor-specific\n");
break;
default:
printf("Unknown type (0x%x)\n", ehdr.e_type);
break;
}
printf(" Machine:\t\t\t\t\t\t");
switch (ehdr.e_machine)
{
case EM_386:
printf("Intel 80386\n");
break;
default:
printf("Unknown type (0x%x)\n", ehdr.e_type);
break;
}
printf(" Version:\t\t\t\t\t\t0x%x\n", ehdr.e_version);
printf(" Entry point address:\t\t\t\t\t0x%x\n", ehdr.e_entry);
printf(" Start of program headers:\t\t\t\t%d (bytes into file)\n", ehdr.e_phoff);
printf(" Start of section headers:\t\t\t\t%d (bytes into file)\n", ehdr.e_shoff);
printf(" Flags:\t\t\t\t\t\t0x%x\n", ehdr.e_flags);
printf(" Size of this header:\t\t\t\t\t%d (bytes)\n", ehdr.e_ehsize);
printf(" Size of program headers:\t\t\t\t%d (bytes)\n", ehdr.e_phentsize);
printf(" Number of program headers:\t\t\t\t%d\n", ehdr.e_phnum);
printf(" Size of section headers:\t\t\t\t%d (bytes)\n", ehdr.e_shentsize);
printf(" Number of section headers:\t\t\t\t%d \n", ehdr.e_shnum);
printf(" Section header string table index:\t\t\t%d \n", ehdr.e_shstrndx);
}
void printElfFunc(const char *fileName)
{
FILE *fd = fopen(fileName, "rb");
if (!fd)
{
perror("Failed to open file");
return;
}
Elf32_Ehdr ehdr;
fread(&ehdr, sizeof(Elf32_Ehdr), 1, fd);
fseek(fd, ehdr.e_shoff, SEEK_SET);
Elf32_Shdr simbolHdr;
Elf32_Shdr stringHdr;
uint8_t strtab = 0;
for (size_t i = 0; i < ehdr.e_shnum; i++)
{
Elf32_Shdr shdr;
fread(&shdr, sizeof(Elf32_Shdr), 1, fd);
if (shdr.sh_type == SHT_SYMTAB)
{
simbolHdr = shdr;
}
else if (shdr.sh_type == SHT_STRTAB)
{
strtab++;
if (strtab == 2)
{
stringHdr = shdr;
}
}
}
size_t numOfSimbols = simbolHdr.sh_size / sizeof(Elf32_Sym);
char name[20];
memset(name, 0, sizeof(name));
printf("%-10s%-10s %-10s%-20s\n", "NR", "Value", "Size", "Name");
int pos = 0;
for (size_t i = 0; i < numOfSimbols; i++)
{
fseek(fd, simbolHdr.sh_offset + i * sizeof(Elf32_Sym), SEEK_SET);
Elf32_Sym sys;
fread(&sys, sizeof(Elf32_Sym), 1, fd);
if (sys.st_size > 50)
{
printf("%-10d", pos++);
printf("0x%-8x ", sys.st_value);
printf("%-10d", sys.st_size);
fseek(fd, stringHdr.sh_offset + sys.st_name, SEEK_SET);
fread(&name, sizeof(name), 1, fd);
printf("%-20s\n", name);
}
}
fclose(fd);
return;
}
void changeElf(int argc, const char **argv)
{
FILE *fd = fopen(argv[2], "r+b");
if (!fd)
{
perror("Failed to open file");
return;
}
Elf32_Ehdr ehdr;
fread(&ehdr, sizeof(Elf32_Ehdr), 1, fd);
fseek(fd, ehdr.e_shoff, SEEK_SET);
Elf32_Shdr simbolHdr;
Elf32_Shdr stringHdr;
uint8_t strtab = 0;
for (size_t i = 0; i < ehdr.e_shnum; i++)
{
Elf32_Shdr shdr;
fread(&shdr, sizeof(Elf32_Shdr), 1, fd);
if (shdr.sh_type == SHT_SYMTAB)
{
simbolHdr = shdr;
}
else if (shdr.sh_type == SHT_STRTAB)
{
strtab++;
if (strtab == 2)
{
stringHdr = shdr;
}
}
}
size_t numOfSimbols = simbolHdr.sh_size / sizeof(Elf32_Sym);
char name[20];
memset(name, 0, sizeof(name));
printf("%-10s\t%s\t\t%s\t%s\t\n", "IME", "NASLOV", "VREDNOST", "NOVA_VREDNOST");
for (unsigned int i = 0; i < numOfSimbols; ++i)
{
fseek(fd, simbolHdr.sh_offset + i * sizeof(Elf32_Sym), SEEK_SET);
Elf32_Sym sys;
fread(&sys, sizeof(Elf32_Sym), 1, fd);
if (!(ELF32_ST_TYPE(sys.st_info) == STT_OBJECT && ELF32_ST_BIND(sys.st_info) == STB_GLOBAL))
continue;
fseek(fd, stringHdr.sh_offset + sys.st_name, SEEK_SET);
fread(&name, sizeof(name), 1, fd);
int con = 1;
for (int j = 3; j < argc; j++)
{
if (strcmp(name, argv[j]) == 0)
{
con = 0;
break;
}
}
if (con)
continue;
printf("%-10s\t", name);
printf("%x\t\t", sys.st_value);
fseek(fd, ehdr.e_shoff + sys.st_shndx * sizeof(Elf32_Shdr), SEEK_SET);
Elf32_Shdr hdr;
fread(&hdr, sizeof(Elf32_Shdr), 1, fd);
uint32_t realAddr = (sys.st_value - hdr.sh_addr) + hdr.sh_offset;
fseek(fd, realAddr, SEEK_SET);
uint32_t val;
fread(&val, sizeof(uint32_t), 1, fd);
printf("%x\t\t", val);
val += 10;
fseek(fd, realAddr, SEEK_SET);
fwrite(&val, sizeof(val), 1, fd);
printf("%x\n", val);
}
fclose(fd);
return;
}

View File

@@ -0,0 +1,4 @@
#include <elf.h>
void printElf(const char *fileName);
void printElfFunc(const char *fileName);
void changeElf(int argc, const char **argv);

View File

@@ -0,0 +1,18 @@
#include <stdio.h>
int funkcija(int a)
{
return a + 1;
}
int g1;
int g2 = 10;
int g3 = 14;
int main()
{
printf("Vrednost g1: %d\n", g1);
printf("Vrednost g2: %d\n", g2);
printf("Vrednost g3: %d\n", g3);
return 0;
}

View File

@@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include "fun.h"
int main(int argc, const char *argv[])
{
if (argc < 3)
{
printf("Usage: %s [-hcl] <elf_path> \n", argv[0]);
exit(1);
}
char var = argv[1][1];
if (var == 'h')
{
printElf(argv[2]);
}
else if (var == 'i')
{
printElfFunc(argv[2]);
}
else if (var == 'c')
{
changeElf(argc, argv);
}
else
{
printf("You entered something else\n");
}
return 0;
}

View File

@@ -0,0 +1,17 @@
all: lib build run clean
build:
gcc -m32 main.c -o demo_eksplicitno -ldl
run:
./demo_eksplicitno "Jaz Sem Velik" 2 5
clean:
rm -f demo_eksplicitno libXPO.a libXPO.o libXPO.so
lib:
gcc -m32 -c libXPO.c -o libXPO.o
gcc -m32 -shared -o libXPO.so libXPO.o
zip:
zip eksplicitno.zip Makefile libXPO.c libXPO.h main.c

View File

@@ -0,0 +1,17 @@
#include "libXPO.h"
#include <string.h>
#include <stdio.h>
uint32_t sestej(uint32_t a, uint32_t b)
{
return a+b;
}
void niz_veliki(char* niz)
{
size_t size = strlen(niz);
for (size_t i = 0; i < size; i++)
if(niz[i] >= 'a' && niz[i] <= 'z')
niz[i] -= 32;
}

View File

@@ -0,0 +1,5 @@
#include <inttypes.h>
#include <stdlib.h>
uint32_t sestej(uint32_t a, uint32_t b);
void niz_veliki(char* niz);

View File

@@ -0,0 +1,71 @@
#include <stdio.h>
#include <dlfcn.h>
#include <locale.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
if(argc < 3){
printf("Usage");
return 0;
}
char* niz = argv[1];
int i = atoi(argv[2]);
int j = atoi(argv[3]);
void* handle = NULL;
void (*izpis)();
int (*vsota)(int,int);
handle = dlopen("./libXPO.so",RTLD_LAZY);
if (handle == NULL)
{
perror("Ne morem odpreti libprva.so\n");
return -1;
}
izpis=(void(*)(void))dlsym(handle,"niz_veliki");
if (izpis==NULL)
{
perror("Ne najdem funkcije izpisi_pozdrav\n");
return -2;
}
izpis(niz);
printf("%s\n", niz);
vsota=(int(*)(int,int))dlsym(handle,"sestej");
if (vsota==NULL)
{
perror("Ne najdem funkcije sestej\n");
return -3;
}
printf("rezultat: %d\n",vsota(i,j));
dlclose(handle);
return 0;
}

View File

@@ -0,0 +1,17 @@
all: lib build run
build:
gcc -m32 main.c -o demo_implicitno -L. -lXPO
run:
./demo_implicitno "Jaz Sem Velik" 2 5
clean:
rm -f demo_implicitno libXPO.a libXPO.o libXPO.so
lib:
gcc -m32 -c libXPO.c -o libXPO.o
gcc -m32 -shared -o libXPO.so libXPO.o
zip:
zip implicitno.zip Makefile libXPO.c libXPO.h main.c

View File

@@ -0,0 +1,17 @@
#include "libXPO.h"
#include <string.h>
#include <stdio.h>
uint32_t sestej(uint32_t a, uint32_t b)
{
return a+b;
}
void niz_veliki(char* niz)
{
size_t size = strlen(niz);
for (size_t i = 0; i < size; i++)
if(niz[i] >= 'a' && niz[i] <= 'z')
niz[i] -= 32;
}

View File

@@ -0,0 +1,5 @@
#include <inttypes.h>
#include <stdlib.h>
uint32_t sestej(uint32_t a, uint32_t b);
void niz_veliki(char* niz);

View File

@@ -0,0 +1,15 @@
#include <stdio.h>
#include "libXPO.h"
//export LD_LIBRARY_PATH=.
int main(int argc, char** argv)
{
char* niz = argv[1];
int i = atoi(argv[2]);
int j = atoi(argv[3]);
niz_veliki(niz);
printf("%s\n", niz);
printf("rezultat: %d\n", sestej(i,j));
return 0;
}

View File

@@ -0,0 +1,17 @@
all: lib build run
build:
gcc -m32 main.c -o demo_staticno libXPO.a
run:
./demo_staticno "Jaz Sem Velik" 5 6
clean:
rm -f demo_staticno libXPO.a libXPO.o
lib:
gcc -m32 -c libXPO.c -o libXPO.o
ar rcs libXPO.a libXPO.o
zip:
zip staticno.zip Makefile libXPO.c libXPO.h main.c

View File

@@ -0,0 +1,17 @@
#include "libXPO.h"
#include <string.h>
#include <stdio.h>
uint32_t sestej(uint32_t a, uint32_t b)
{
return a+b;
}
void niz_veliki(char* niz)
{
size_t size = strlen(niz);
for (size_t i = 0; i < size; i++)
if(niz[i] >= 'a' && niz[i] <= 'z')
niz[i] -= 32;
}

View File

@@ -0,0 +1,5 @@
#include <inttypes.h>
#include <stdlib.h>
uint32_t sestej(uint32_t a, uint32_t b);
void niz_veliki(char* niz);

View File

@@ -0,0 +1,14 @@
#include <stdio.h>
#include "libXPO.h"
int main(int argc, char** argv)
{
char* niz = argv[1];
int i = atoi(argv[2]);
int j = atoi(argv[3]);
niz_veliki(niz);
printf("%s\n", niz);
printf("rezultat: %d\n", sestej(i,j));
return 0;
}

View File

@@ -0,0 +1,51 @@
################################################################################################################
#
# STATICNA KNJIZNICA
################################################################################################################
$ gcc -c libprva.c -o libprva.o
$ ar rcs libprva.a libprva.o
r - Insert the files member into archive (with replacement)
c - Create the archive. The specified archive is always created if it did not exist, when you request an update
s - Write an object-file index into the archive, or update an existing one
$ gcc implicitna.c -o staticna libprva.a
################################################################################################################
#
# DINAMICNA KNJIZNICA
################################################################################################################
$ gcc -c -fPIC libprva.c
$ ld -shared -soname libprva.so.1 -o libprva.so.1.0 libprva.o
$ ldconfig -v -n .
$ ln -sf libprva.so.1 libprva.so
################################################################################################################
#
# DINAMICNA KNJIZNICA IMPLICITNO POVEZOVANJE
################################################################################################################
$ gcc implicitna.c -o implicitna -L. -lprva
#Ker uporabljamo dinamične knjižnice moramo program prevesti z dodatnimi zastavicami. Uporabiti moramo zastavico -L, s katero povemo, kje naj povezovalnik išče knjižnice in zastavico -l s katero vključimo knjižnico v program.
$ export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
#Preden lahko program zaženemo mu moramo na nek način sporočiti, kje lahko najde dinamično knjižnico. Ponavadi se vse knjižnice nahajajo v mapi /usr/lib, /usr/local/lib oz mapah, navedenih v datoteki /etc/ld.so.conf. Knjižnice se iščejo tudi v poteh navedenih v spremenljivki LD_LIBRARY_PATH. V našem primeru bomo knjižnico imeli kar v trenutni mapi, ki jo bomo dodali v spremenljivko z ukazom:
$ ./implicitna # Sedaj lahko zaženemo program.
$ strip --strip-unneeded implicitna
################################################################################################################
#
# DINAMICNA KNJIZNICA EXPLICITNO POVEZOVANJE
################################################################################################################
$ gcc eksplicitno.c -o eksplicitna -ldl
# Da lahko prevedemo program, moramo zraven vključiti še knjižnico libdl. Pri gcc uporabimo torej še zastavico -ldl.
$ strip --strip-unneeded eksplicitna

View File

@@ -0,0 +1,18 @@
all: libprva.o
ld -shared -soname libprva.so.1 -o libprva.so.1.0 libprva.o
ldconfig -v -n .
ln -sf libprva.so.1 libprva.so
gcc implicitna.c -o implicitna -L. -lprva
gcc eksplicitno.c -o eksplicitna -ldl
libprva.o: libprva.c
gcc -c -fPIC libprva.c
clean:
rm -f libprva.o
rm -f libprva.so.1.0
rm -f libprva.so.1
rm -f libprva.so
rm -f implicitna
rm -f eksplicitna

View File

@@ -0,0 +1,5 @@
# Knjižnice
## Prevajanje in vključevanje zunanjih modulov
Za demonstracijo preverite zbirko ukazi.txt.

View File

@@ -0,0 +1,60 @@
#include <dlfcn.h>
#include <locale.h>
#include <stdio.h>
int main()
{
void* handle = NULL;
void (*izpis)();
int (*vsota)(int,int);
printf("Primer eksplicitne uporabe dinamicnih knjiznic\n");
handle = dlopen("./libprva.so",RTLD_LAZY);
if (handle == NULL)
{
perror("Ne morem odpreti libprva.so\n");
return -1;
}
/* Klic prve funkcije */
izpis=(void(*)(void))dlsym(handle,"izpisi_pozdrav");
if (izpis==NULL)
{
perror("Ne najdem funkcije izpisi_pozdrav\n");
return -2;
}
izpis();
/* Klic druge funkcije */
vsota=(int(*)(int,int))dlsym(handle,"vrni_vsoto");
if (vsota==NULL)
{
perror("Ne najdem funkcije vrni_vsota\n");
return -3;
}
printf("Vsota: %d\n",vsota(40,2));
/* Klic tretje funkcije */
void (*izpisi_niz)(char*);
izpisi_niz=(void(*)(char*))dlsym(handle,"izpisi_niz");
if (izpisi_niz==NULL)
{
perror("Ne najdem funkcije izpisi_niz\n");
return -7;
}
izpisi_niz("Niz, ki ga izpise 3. funkcija!");
/* Spremenljivka */
int *spremenljivka;
spremenljivka=(int *)dlsym(handle,"vrednost");
if (spremenljivka==NULL)
{
perror("Ne najdem spremenljivke vrednost\n");
return -7;
}
printf("Spremenljivka ima vrednost: %d\n",*spremenljivka);
dlclose(handle);
return 0;
}

View File

@@ -0,0 +1,20 @@
#include <stdio.h>
#include "libprva.h"
int main()
{
char *niz="Niz iz glavnega programa\0";
printf("-----Zacetek-----\n");
izpisi_pozdrav();
printf("-----------------\n");
vrednost=42;
kazalec=(int *)niz;
izpisi_pozdrav();
printf("-----------------\n");
int v=vrni_vsoto(2,3);
printf("Vrnjena vsota je %d\n", v);
printf("-----------------\n");
izpisi_niz(niz);
printf("-------Konec-----\n");
return 0;
}

View File

@@ -0,0 +1,29 @@
#include <stdio.h>
/* Primer spremenljivke*/
int vrednost=999;
/* Primer kazalca */
int* kazalec;
/* Primer funkcije brez parametrov */
void izpisi_pozdrav()
{
printf("Pozdrav iz dinamicne knjiznice.\n");
printf("Spremenljivka vrednost je: %d\n ",vrednost);
printf("Kazalec kaze na naslov: %p\n",kazalec);
}
/* Primer funkcije z enim vhodnim in dvema vhodnima parametroma*/
int vrni_vsoto(int a, int b)
{
printf("Vsota je %d\n",a+b);
return a+b;
}
/* Primer funkcije, ki ima kot vhod kazalec na niz (zero terminated)*/
void izpisi_niz(char* niz)
{
printf("Vhodni niz: %s\n",niz);
}

View File

@@ -0,0 +1,9 @@
/* Prototipi funkcij in spremenljivk */
extern int vrednost;
extern int* kazalec;
void izpisi_pozdrav();
int vrni_vsoto(int a, int b);
void izpisi_niz(char* niz);

View File

@@ -0,0 +1,529 @@
################################################################################################################
#
# STATICNA KNJIZNICA
################################################################################################################
$ gcc -c libprva.c -o libprva.o
$ ar rcs libprva.a libprva.o
r - Insert the files member into archive (with replacement)
c - Create the archive. The specified archive is always created if it did not exist, when you request an update
s - Write an object-file index into the archive, or update an existing one
$ gcc implicitna.c -o staticna libprva.a
$ readelf -h libprva.a # izpise zaglavje formata ELF od knjižnice
" ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 592 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 13
Section header string table index: 10
"
$ readelf -h ./staticna # izpise zaglavje formata ELF od izvedljivega modula
" ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x400460
Start of program headers: 64 (bytes into file)
Start of section headers: 6320 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 34
"
$ readelf -S -W libprva.a # izpise vse sekcije
" There are 13 section headers, starting at offset 0x250:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 0000000000000000 000040 00008c 00 AX 0 0 4
[ 2] .rela.text RELA 0000000000000000 000760 000120 18 11 1 8
[ 3] .data PROGBITS 0000000000000000 0000cc 000004 00 WA 0 0 4
[ 4] .bss NOBITS 0000000000000000 0000d0 000000 00 WA 0 0 4
[ 5] .rodata PROGBITS 0000000000000000 0000d0 000079 00 A 0 0 8
[ 6] .eh_frame PROGBITS 0000000000000000 000150 000078 00 A 0 0 8
[ 7] .rela.eh_frame RELA 0000000000000000 000880 000048 18 11 6 8
[ 8] .comment PROGBITS 0000000000000000 0001c8 000024 00 0 0 1
[ 9] .note.GNU-stack PROGBITS 0000000000000000 0001ec 000000 00 0 0 1
[10] .shstrtab STRTAB 0000000000000000 0001ec 000061 00 0 0 1
[11] .symtab SYMTAB 0000000000000000 000590 000180 18 12 9 8
[12] .strtab STRTAB 0000000000000000 000710 00004d 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
"
$ readelf -s libprva.a # izpise simbolno tabelo knjiznice
" File: libprva.a(libprva.o)
Symbol table '.symtab' contains 16 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS libprva.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 3
4: 0000000000000000 0 SECTION LOCAL DEFAULT 4
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000000 0 SECTION LOCAL DEFAULT 6
7: 0000000000000000 0 SECTION LOCAL DEFAULT 9
8: 0000000000000000 0 SECTION LOCAL DEFAULT 8
9: 0000000000000000 4 OBJECT GLOBAL DEFAULT 3 vrednost
10: 0000000000000000 59 FUNC GLOBAL DEFAULT 1 izpisi_pozdrav
11: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND puts
12: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND printf
13: 0000000000000008 8 OBJECT GLOBAL DEFAULT COM kazalec
14: 000000000000003b 48 FUNC GLOBAL DEFAULT 1 vrni_vsoto
15: 000000000000006b 33 FUNC GLOBAL DEFAULT 1 izpisi_niz
"
$ readelf -r libprva.a # izpise relokacijske tabele knjiznice
"
Relocation section '.rela.text' at offset 0x760 contains 12 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000005 00050000000a R_X86_64_32 0000000000000000 .rodata + 0
00000000000a 000b00000002 R_X86_64_PC32 0000000000000000 puts + fffffffffffffffc
000000000010 000900000002 R_X86_64_PC32 0000000000000000 vrednost + fffffffffffffffc
000000000015 00050000000a R_X86_64_32 0000000000000000 .rodata + 20
00000000001f 000c00000002 R_X86_64_PC32 0000000000000000 printf + fffffffffffffffc
000000000026 000d00000002 R_X86_64_PC32 0000000000000008 kazalec + fffffffffffffffc
00000000002b 00050000000a R_X86_64_32 0000000000000000 .rodata + 40
000000000035 000c00000002 R_X86_64_PC32 0000000000000000 printf + fffffffffffffffc
000000000053 00050000000a R_X86_64_32 0000000000000000 .rodata + 5c
00000000005d 000c00000002 R_X86_64_PC32 0000000000000000 printf + fffffffffffffffc
00000000007c 00050000000a R_X86_64_32 0000000000000000 .rodata + 69
000000000086 000c00000002 R_X86_64_PC32 0000000000000000 printf + fffffffffffffffc
Relocation section '.rela.eh_frame' at offset 0x880 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 00020000000a R_X86_64_32 0000000000000000 .text + 0
000000000040 00020000000a R_X86_64_32 0000000000000000 .text + 3b
000000000060 00020000000a R_X86_64_32 0000000000000000 .text + 6b
"
Offset . odmik od zacetka sekcije do mesta prenaslavljanja
Info - vstop v simbolno tabelo in tip prenaslavljanja
Sym.Value - vrednost simbola v simbolni tabeli
Sym.Name -ime simbola v simboni tabeli
$ readelf -s ./staticna # izpise simbolno tabelo izvedljivega modula
"
Symbol table '.dynsym' contains...
"
$ readelf -r ./staticna # izpise relokacijske tabele izvedljivega modula
"
Relocation section '.rela.dyn' at offset 0x3a8 contains 1 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000600fe0 000200000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0
Relocation section '.rela.plt' at offset 0x3c0 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000601000 000100000007 R_X86_64_JUMP_SLO 0000000000000000 printf + 0
000000601008 000300000007 R_X86_64_JUMP_SLO 0000000000000000 puts + 0
000000601010 000400000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main + 0
"
Offset . odmik od zacetka sekcije do mesta prenaslavljanja
Info - vstop v simbolno tabelo in tip prenaslavljanja
Sym.Value - vrednost simbola v simbolni tabeli
Sym.Name -ime simbola v simboni tabeli
$ strip --strip-unneeded staticna # odstranimo vse nepotrebne simbole
$ readelf -s ./staticna # izpisemo simbolno tabelo
"
Symbol table '.dynsym' contains 5 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.2.5 (2)
2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2)
4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (2)
"
################################################################################################################
#
# DINAMICNA KNJIZNICA
################################################################################################################
#Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system).
$ gcc -c -fPIC libprva.c
$ readelf -r libprva.o # izpise relokacijske tabele izvedljivega modula
"
Relocation section '.rela.text' at offset 0x7a0 contains 12 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000007 000500000002 R_X86_64_PC32 0000000000000000 .rodata + fffffffffffffffc
00000000000c 000c00000004 R_X86_64_PLT32 0000000000000000 puts + fffffffffffffffc
000000000013 000900000009 R_X86_64_GOTPCREL 0000000000000000 vrednost + fffffffffffffffc
00000000001c 000500000002 R_X86_64_PC32 0000000000000000 .rodata + 1c
000000000026 000d00000004 R_X86_64_PLT32 0000000000000000 printf + fffffffffffffffc
00000000002d 000e00000009 R_X86_64_GOTPCREL 0000000000000008 kazalec + fffffffffffffffc
000000000037 000500000002 R_X86_64_PC32 0000000000000000 .rodata + 3c
000000000041 000d00000004 R_X86_64_PLT32 0000000000000000 printf + fffffffffffffffc
000000000061 000500000002 R_X86_64_PC32 0000000000000000 .rodata + 58
00000000006b 000d00000004 R_X86_64_PLT32 0000000000000000 printf + fffffffffffffffc
00000000008c 000500000002 R_X86_64_PC32 0000000000000000 .rodata + 65
000000000096 000d00000004 R_X86_64_PLT32 0000000000000000 printf + fffffffffffffffc
Relocation section '.rela.eh_frame' at offset 0x8c0 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
000000000040 000200000002 R_X86_64_PC32 0000000000000000 .text + 47
000000000060 000200000002 R_X86_64_PC32 0000000000000000 .text + 79
"
#Primerjaj z $ readelf -r libprva.a
$ ld -shared -soname libprva.so.1 -o libprva.so.1.0 libprva.o
# Z zastavico -shared povemo, da se mora modul pred izvajanjem povezal še z drugimi moduli (torej nima vstopne točke), z zastavico -soname ime_datoteke.so.verzija_vmesnika pa povemo, katera verzija vmesnika je implementirana. Vedno ko spremenimo vmesnik knjižnice, moramo spremeniti tudi to verzijo, saj se na ta način izognemo težavam z nekompatibilnimi knjižnicami. Vidimo, da ima tudi izhodni modul na koncu dve številki. Prva pove številko vmesnika, druga pa njegovo verzijo.
$ ldconfig -v -n .
" .:
libprva.so.1 -> libprva.so.1.0 (changed)
"
#Dobili smo knjižnico, ki jo moramo sedaj še namestiti. V kolikor jo želimo dani na voljo vsem, jo kopiramo v mapo /usr/lib ali /lib, v našem primeru pa jo bomo pustili kar v trenutni mapi. V vsakem primeru pa moramo pognati ukaz ldconfig, ki poišče zadnjo verzijo vsake knjižnice. V našem primeru smo napisali ukaz, ki bo iskal nove verzije samo v trenutni mapi.
# zastavice
# -v --verbose
# Verbose mode. Print current version number, the name of each directory as it is scanned and any links that are
# created.
# -n Only process directories specified on the command line. Dont process the trusted directories (/usr/lib and
# /lib) nor those specified in /etc/ld.so.conf. Implies -N.
$ ls -all
# Sedaj je ustvarjena nova povezava z imenom libprva.so.1, ki kaže na libprva.so.1.0. Ukaz "ldconfig -v -n ." torej poskrbi, da nam ni potrebno skrbeti za podverzijo knjižnice.
$ ln -sf libprva.so.1 libprva.so
# Na koncu lahko naredimo še simbolično povezavo do te knjižnice (man ln)
$ ls -all
# bodite pozorni na simbolično povezavo libprva.so -> libprva.so.1
$ readelf -h libprva.so
" ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x380
Start of program headers: 64 (bytes into file)
Start of section headers: 1840 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 4
Size of section headers: 64 (bytes)
Number of section headers: 19
Section header string table index: 16
"
$ readelf -s libprva.so
"Symbol table '.dynsym' contains 12 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000380 0 SECTION LOCAL DEFAULT 7
2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND printf
3: 0000000000000380 71 FUNC GLOBAL DEFAULT 7 izpisi_pozdrav
4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND puts
5: 0000000000200688 8 OBJECT GLOBAL DEFAULT 14 kazalec
6: 00000000000003f9 35 FUNC GLOBAL DEFAULT 7 izpisi_niz
7: 00000000000003c7 50 FUNC GLOBAL DEFAULT 7 vrni_vsoto
8: 0000000000200684 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
9: 0000000000200684 0 NOTYPE GLOBAL DEFAULT ABS _edata
10: 0000000000200690 0 NOTYPE GLOBAL DEFAULT ABS _end
11: 0000000000200680 4 OBJECT GLOBAL DEFAULT 13 vrednost
Symbol table '.symtab' contains 29 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
...
16: 0000000000000000 0 FILE LOCAL DEFAULT ABS libprva.c
17: 0000000000200518 0 OBJECT LOCAL HIDDEN ABS _DYNAMIC
18: 0000000000200658 0 OBJECT LOCAL HIDDEN ABS _GLOBAL_OFFSET_TABLE_
19: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND printf
20: 0000000000000380 71 FUNC GLOBAL DEFAULT 7 izpisi_pozdrav
21: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND puts
22: 0000000000200688 8 OBJECT GLOBAL DEFAULT 14 kazalec
23: 00000000000003f9 35 FUNC GLOBAL DEFAULT 7 izpisi_niz
24: 00000000000003c7 50 FUNC GLOBAL DEFAULT 7 vrni_vsoto
25: 0000000000200684 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
26: 0000000000200684 0 NOTYPE GLOBAL DEFAULT ABS _edata
27: 0000000000200690 0 NOTYPE GLOBAL DEFAULT ABS _end
28: 0000000000200680 4 OBJECT GLOBAL DEFAULT 13 vrednost
"
# Simbolna tabela .symtab podvaja vrednosti dinamične simbolne tabele .dynsym
#Primerjaj z $ readelf -s libprva.a
$ readelf -r libprva.so
"
Relocation section '.rela.dyn' at offset 0x2f0 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000200648 000500000006 R_X86_64_GLOB_DAT 0000000000200688 kazalec + 0
000000200650 000b00000006 R_X86_64_GLOB_DAT 0000000000200680 vrednost + 0
Relocation section '.rela.plt' at offset 0x320 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000200670 000200000007 R_X86_64_JUMP_SLO 0000000000000000 printf + 0
000000200678 000400000007 R_X86_64_JUMP_SLO 0000000000000000 puts + 0
"
$ readelf -SW libprva.so # izpisemo vse sekcije
" There are 19 section headers, starting at offset 0x730:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .hash HASH 0000000000000120 000120 000044 04 A 2 0 8
[ 2] .dynsym DYNSYM 0000000000000168 000168 000120 18 A 3 2 8
[ 3] .dynstr STRTAB 0000000000000288 000288 000068 00 A 0 0 1
[ 4] .rela.dyn RELA 00000000000002f0 0002f0 000030 18 A 2 0 8
[ 5] .rela.plt RELA 0000000000000320 000320 000030 18 A 2 6 8
[ 6] .plt PROGBITS 0000000000000350 000350 000030 10 AX 0 0 4
[ 7] .text PROGBITS 0000000000000380 000380 00009c 00 AX 0 0 4
[ 8] .rodata PROGBITS 0000000000000420 000420 000079 00 A 0 0 8
[ 9] .eh_frame PROGBITS 00000000000004a0 0004a0 000078 00 A 0 0 8
[10] .dynamic DYNAMIC 0000000000200518 000518 000130 10 WA 3 0 8
[11] .got PROGBITS 0000000000200648 000648 000010 08 WA 0 0 8
[12] .got.plt PROGBITS 0000000000200658 000658 000028 08 WA 0 0 8
[13] .data PROGBITS 0000000000200680 000680 000004 00 WA 0 0 4
[14] .bss NOBITS 0000000000200688 000684 000008 00 WA 0 0 8
[15] .comment PROGBITS 0000000000000000 000684 000024 00 0 0 1
[16] .shstrtab STRTAB 0000000000000000 0006a8 000088 00 0 0 1
[17] .symtab SYMTAB 0000000000000000 000bf0 0002b8 18 18 19 8
[18] .strtab STRTAB 0000000000000000 000ea8 000084 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
"
$ objdump -d -j .plt libprva.so # izpišemo vsebino sekcije plt (Procedure Linkage Table)
"
libprva.so: file format elf64-x86-64
Disassembly of section .plt:
0000000000000350 <printf@plt-0x10>:
350: ff 35 0a 03 20 00 pushq 0x20030a(%rip) # 200660 <_GLOBAL_OFFSET_TABLE_+0x8>
356: ff 25 0c 03 20 00 jmpq *0x20030c(%rip) # 200668 <_GLOBAL_OFFSET_TABLE_+0x10>
35c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000000360 <printf@plt>:
360: ff 25 0a 03 20 00 jmpq *0x20030a(%rip) # 200670 <_GLOBAL_OFFSET_TABLE_+0x18>
366: 68 00 00 00 00 pushq $0x0
36b: e9 e0 ff ff ff jmpq 350 <printf@plt-0x10>
0000000000000370 <puts@plt>:
370: ff 25 02 03 20 00 jmpq *0x200302(%rip) # 200678 <_GLOBAL_OFFSET_TABLE_+0x20>
376: 68 01 00 00 00 pushq $0x1
37b: e9 d0 ff ff ff jmpq 350 <printf@plt-0x10>
"
# za razlago delovanje tabele plt glej slikovni material na sistemu za vaje
$ objdump -s libprva.so | grep -A 2 got
"
Contents of section .got:
200648 00000000 00000000 00000000 00000000 ................
Contents of section .got.plt:
200658 18052000 00000000 00000000 00000000 .. .............
200668 00000000 00000000 66030000 00000000 ........f.......
"
$ readelf -I libprva.so
"
Histogram for bucket list length (total of 3 buckets):
Length Number % of total Coverage
0 0 ( 0.0%)
1 1 ( 33.3%) 10.0%
2 1 ( 33.3%) 30.0%
3 0 ( 0.0%) 30.0%
4 0 ( 0.0%) 30.0%
5 0 ( 0.0%) 30.0%
6 0 ( 0.0%) 30.0%
7 1 ( 33.3%) 100.0%
"
# 3 buckets - trije vstopi v hash tabelo
# length - dolžina verige (chain) v hash tabeli
# number - število vstopov v hash tabelo s specificirano dolžino verige
# še malo večji primer .so knjižnice
$ readelf -I /lib/libc.so.6
" Histogram for bucket list length (total of 1017 buckets):
Length Number % of total Coverage
0 116 ( 11.4%)
1 268 ( 26.4%) 12.7%
2 283 ( 27.8%) 39.4%
3 194 ( 19.1%) 66.9%
4 100 ( 9.8%) 85.8%
5 40 ( 3.9%) 95.3%
6 12 ( 1.2%) 98.7%
7 4 ( 0.4%) 100.0%
"
$ sudo apt-get install elfutils # eu-readelf pove še povprečno število iskanj v hash tabeli...
$ eu-readelf -I libprva.so
"
Histogram for bucket list length in section [ 1] '.hash' (total of 3 buckets):
Addr: 0x0000000000000120 Offset: 0x000120 Link to section: [ 2] '.dynsym'
Length Number % of total Coverage
0 0 0.0%
1 1 33.3% 10.0%
2 1 33.3% 30.0%
3 0 0.0% 30.0%
4 0 0.0% 30.0%
5 0 0.0% 30.0%
6 0 0.0% 30.0%
7 1 33.3% 100.0%
Average number of tests: successful lookup: 3.200000
unsuccessful lookup: 3.333333
"
$ eu-readelf -I /lib/libc.so.6
################################################################################################################
#
# DINAMICNA KNJIZNICA IMPLICITNO POVEZOVANJE
################################################################################################################
$ gcc implicitna.c -o implicitna -L. -lprva
#Ker uporabljamo dinamične knjižnice moramo program prevesti z dodatnimi zastavicami. Uporabiti moramo zastavico -L, s katero povemo, kje naj povezovalnik išče knjižnice in zastavico -l s katero vključimo knjižnico v program.
$ export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
#Preden lahko program zaženemo mu moramo na nek način sporočiti, kje lahko najde dinamično knjižnico. Ponavadi se vse knjižnice nahajajo v mapi /usr/lib, /usr/local/lib oz mapah, navedenih v datoteki /etc/ld.so.conf. Knjižnice se iščejo tudi v poteh navedenih v spremenljivki LD_LIBRARY_PATH. V našem primeru bomo knjižnico imeli kar v trenutni mapi, ki jo bomo dodali v spremenljivko z ukazom:
$ ./implicitna # Sedaj lahko zaženemo program.
$ readelf -h ./implicitna
" ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x400670
Start of program headers: 64 (bytes into file)
Start of section headers: 6304 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 34
"
$ readelf -s ./implicitna
"
Symbol table '.dynsym' contains 13 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.2.5 (2)
2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND vrni_vsoto
3: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2)
5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND izpisi_niz
6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (2)
7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND izpisi_pozdrav
8: 0000000000601060 0 NOTYPE GLOBAL DEFAULT ABS _end
9: 0000000000601040 0 NOTYPE GLOBAL DEFAULT ABS _edata
10: 0000000000601040 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
11: 0000000000601040 4 OBJECT GLOBAL DEFAULT 25 vrednost
12: 0000000000601048 8 OBJECT GLOBAL DEFAULT 25 kazalec
"
# primirjaj z $ readelf -s ./staticna
$ readelf -r ./implicitna
"
Relocation section '.rela.dyn' at offset 0x510 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000600fe0 000300000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0
000000601040 000b00000005 R_X86_64_COPY 0000000000601040 vrednost + 0
000000601048 000c00000005 R_X86_64_COPY 0000000000601048 kazalec + 0
Relocation section '.rela.plt' at offset 0x558 contains 6 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000601000 000100000007 R_X86_64_JUMP_SLO 0000000000000000 printf + 0
000000601008 000200000007 R_X86_64_JUMP_SLO 0000000000000000 vrni_vsoto + 0
000000601010 000400000007 R_X86_64_JUMP_SLO 0000000000000000 puts + 0
000000601018 000500000007 R_X86_64_JUMP_SLO 0000000000000000 izpisi_niz + 0
000000601020 000600000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main + 0
000000601028 000700000007 R_X86_64_JUMP_SLO 0000000000000000 izpisi_pozdrav + 0
"
# primerjaj z $ readelf -r ./staticna
$ strip --strip-unneeded implicitna
$ readelf -s ./implicitna
################################################################################################################
#
# DINAMICNA KNJIZNICA EXPLICITNO POVEZOVANJE
################################################################################################################
$ gcc eksplicitno.c -o eksplicitna -ldl
# Da lahko prevedemo program, moramo zraven vključiti še knjižnico libdl. Pri gcc uporabimo torej še zastavico -ldl.
$ readelf -h ./eksplicitna
"
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x400600
Start of program headers: 64 (bytes into file)
Start of section headers: 6320 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 34
"
$ readelf -s ./eksplicitna
"
...
"
$ readelf -r ./eksplicitna
" Relocation section '.rela.dyn' at offset 0x4a0 contains 1 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000600fe0 000200000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0
Relocation section '.rela.plt' at offset 0x4b8 contains 7 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000601000 000100000007 R_X86_64_JUMP_SLO 0000000000000000 printf + 0
000000601008 000400000007 R_X86_64_JUMP_SLO 0000000000000000 puts + 0
000000601010 000500000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main + 0
000000601018 000600000007 R_X86_64_JUMP_SLO 0000000000000000 dlclose + 0
000000601020 000700000007 R_X86_64_JUMP_SLO 0000000000000000 dlopen + 0
000000601028 000800000007 R_X86_64_JUMP_SLO 0000000000000000 dlsym + 0
000000601030 000900000007 R_X86_64_JUMP_SLO 0000000000000000 perror + 0
"
# primerjaj z $ readelf -r ./staticna
# primerjaj z $ readelf -r ./implicitna
$ strip --strip-unneeded eksplicitna
$ readelf -s ./eksplicitna

View File

@@ -0,0 +1,29 @@
obj-m += xpo_modul.o
all: build
build:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
load:
sudo insmod xpo_modul.ko
unload:
sudo rmmod xpo_modul
list:
sudo lsmod | grep xpo
msg:
sudo dmesg | grep xpo
start:
sudo watch -n 0.2 "cat /dev/xpo_modul"
restart: msg unload build load
zip:
zip naloga.zip Makefile xpo_modul.c xpo_modul.h

View File

@@ -0,0 +1,116 @@
#include <linux/atomic.h>
#include <linux/cdev.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/kernel.h> /* for sprintf() */
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/types.h>
#include"xpo_modul.h"
MODULE_AUTHOR("NIKOLA");
MODULE_DESCRIPTION("Simple kernel driver skeleton");
MODULE_LICENSE("GPL");
static int major; // major number of device driver
#define DEVICE_NAME "xpo_modul"
static struct class *cls;
static int __init xpo_driver_init(void)
{
pr_info("xpo: driver INIT\n");
major = register_chrdev(0, DEVICE_NAME, &xpo_fops);
if (major < 0) {
pr_alert("xpo: registering char device failed with %d\n", major);
return major;
} else {
pr_info("xpo: registering char device %d\n", major);
}
cls = class_create(THIS_MODULE, DEVICE_NAME);
device_create(cls, NULL, MKDEV(major, 0), NULL, DEVICE_NAME);
pr_info("xpo: Device created on /dev/%s\n", DEVICE_NAME);
return 0;
}
static void xpo_driver_exit(void)
{
pr_info("xpo: driver EXIT\n");
device_destroy(cls, MKDEV(major, 0));
class_destroy(cls);
unregister_chrdev(major, DEVICE_NAME);
return ;
}
module_init(xpo_driver_init);
module_exit(xpo_driver_exit);
// abcdefghijklmnopqrstuvwxyz
static unsigned char xpo_map[256] =
{
[0 ... 255] = 0,
[2] = '1',
[3] = '2',
[4] = '3',
[5] = '4',
[6] = '5',
[7] = '6',
[8] = '7',
[9] = '8',
[10] = '9',
[11] = '0',
[16] = 'q',
[17] = 'w',
[18] = 'e',
[19] = 'r',
[20] = 't',
[21] = 'z',
[22] = 'u',
[23] = 'i',
[24] = 'o',
[25] = 'p',
[30] = 'a',
[31] = 's',
[32] = 'd',
[33] = 'f',
[34] = 'g',
[35] = 'h',
[36] = 'j',
[37] = 'k',
[37] = 'l',
[44] = 'y',
[45] = 'x',
[46] = 'c',
[47] = 'v',
[48] = 'b',
[49] = 'n',
[50] = 'm'
};
ssize_t xpo_read(struct file *filep, char *buff, size_t count, loff_t *offp )
{
unsigned char c = inb(0x60); // 0x60 - which key down
char buf[20];
sprintf(buf, "%u - znak: %c", c, xpo_map[c]);
printk("xpo - signal: %s\n", buf);
return 0;
}

View File

@@ -0,0 +1,20 @@
#ifndef _MY_DEVICE_H
#define _MY_DEVICE_H
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <asm/current.h>
#include <asm/segment.h>
#include <linux/uaccess.h>
#include <asm/io.h>
ssize_t xpo_read(struct file *filep, char *buff, size_t count, loff_t *offp );
struct file_operations xpo_fops={
read: xpo_read,
};
#endif

View File

@@ -0,0 +1,27 @@
obj-m += xpo_xor_module.o
all: build
build:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
load:
sudo insmod xpo_xor_module.ko
unload:
sudo rmmod xpo_xor_module
read:
sudo cat /dev/xpo_xor_module
write1:
sudo echo "NikolaJeVelik" > /dev/xpo_xor_module
write2:
sudo echo "1234567890NikolaJeVelokMozKiHodiNaFaksInJeVMariboruInSedajDelaNalogoSajmujedolgcajtinbirajepocelkajdrugega" > /dev/xpo_xor_module
zip:
zip naloga.zip Makefile xpo_xor_module.c xpo_xor_module.h

Some files were not shown because too many files have changed in this diff Show More