Is there a way to populate an ellipses parameter programmatically?
I'm going to be getting in data from a file of my own making. This file will contain a printf format string and the parameters passed to it. I've already generated this code.
Now I want to do the reverse. Read format string and the parameters and pass it back to printf functions. Can I somehow generate the appropriate call stack or am I going to have to reparse the format string and send it to printf()
piecemeal?
Edit
I know the risks with the printf functions. I understand that there are security vulnerabilities. These issues are non-issues as:
- This is to be used in a debugging context. Not to be handled outside of that scope.
- Executable that reads the file, is executed by the person who made the file.
- The datafile created will be read by an executable that simply expands the file and is not accessible by a third party.
- It has no access to writing anything to memory (
%n
is not valid).
Use Case
To compress a stream with minimal CPU overhead by tracking constantly repeating strings and replacing them with enumerations. All other data is saved as binary data, thus requiring only minimal processing instead of having to convert it to a large string every time.
c++
|
show 11 more comments
I'm going to be getting in data from a file of my own making. This file will contain a printf format string and the parameters passed to it. I've already generated this code.
Now I want to do the reverse. Read format string and the parameters and pass it back to printf functions. Can I somehow generate the appropriate call stack or am I going to have to reparse the format string and send it to printf()
piecemeal?
Edit
I know the risks with the printf functions. I understand that there are security vulnerabilities. These issues are non-issues as:
- This is to be used in a debugging context. Not to be handled outside of that scope.
- Executable that reads the file, is executed by the person who made the file.
- The datafile created will be read by an executable that simply expands the file and is not accessible by a third party.
- It has no access to writing anything to memory (
%n
is not valid).
Use Case
To compress a stream with minimal CPU overhead by tracking constantly repeating strings and replacing them with enumerations. All other data is saved as binary data, thus requiring only minimal processing instead of having to convert it to a large string every time.
c++
Neither.snprintf()
is prehistoric C. Modern C++ code uses the streams library, that implements formatted output in a fundamentally different way. If someone's intent is to learn modern C++, they should not be wasting their time on old-style C formatting.
– Sam Varshavchik
Nov 23 '18 at 2:50
related: stackoverflow.com/q/150543/1132334
– dlatikay
Nov 23 '18 at 2:50
This also creates a pretty glaring security vulnerability.
– Peter Ruderman
Nov 23 '18 at 2:52
@PeterRuderman, the security vulnerability is negligible as it is for local logging and not for public consumption.
– Adrian
Nov 23 '18 at 2:55
1
It is true that streams have higher overhead than C-style stdio formatting. However, with modern, multi-Ghz CPUs, this only becomes an issue when generating huge amounts of output. Any difference in "throughput" between streams and C-style stdio formatting is mostly academic, otherwise. And, with C++ streams you get type-safety. The best way to avoid writings bugs is to make it logically impossible to create them; and type-safety makes many classes of bugs logically impossible.
– Sam Varshavchik
Nov 23 '18 at 3:39
|
show 11 more comments
I'm going to be getting in data from a file of my own making. This file will contain a printf format string and the parameters passed to it. I've already generated this code.
Now I want to do the reverse. Read format string and the parameters and pass it back to printf functions. Can I somehow generate the appropriate call stack or am I going to have to reparse the format string and send it to printf()
piecemeal?
Edit
I know the risks with the printf functions. I understand that there are security vulnerabilities. These issues are non-issues as:
- This is to be used in a debugging context. Not to be handled outside of that scope.
- Executable that reads the file, is executed by the person who made the file.
- The datafile created will be read by an executable that simply expands the file and is not accessible by a third party.
- It has no access to writing anything to memory (
%n
is not valid).
Use Case
To compress a stream with minimal CPU overhead by tracking constantly repeating strings and replacing them with enumerations. All other data is saved as binary data, thus requiring only minimal processing instead of having to convert it to a large string every time.
c++
I'm going to be getting in data from a file of my own making. This file will contain a printf format string and the parameters passed to it. I've already generated this code.
Now I want to do the reverse. Read format string and the parameters and pass it back to printf functions. Can I somehow generate the appropriate call stack or am I going to have to reparse the format string and send it to printf()
piecemeal?
Edit
I know the risks with the printf functions. I understand that there are security vulnerabilities. These issues are non-issues as:
- This is to be used in a debugging context. Not to be handled outside of that scope.
- Executable that reads the file, is executed by the person who made the file.
- The datafile created will be read by an executable that simply expands the file and is not accessible by a third party.
- It has no access to writing anything to memory (
%n
is not valid).
Use Case
To compress a stream with minimal CPU overhead by tracking constantly repeating strings and replacing them with enumerations. All other data is saved as binary data, thus requiring only minimal processing instead of having to convert it to a large string every time.
c++
c++
edited Nov 23 '18 at 3:32
asked Nov 23 '18 at 2:45
Adrian
3,90322057
3,90322057
Neither.snprintf()
is prehistoric C. Modern C++ code uses the streams library, that implements formatted output in a fundamentally different way. If someone's intent is to learn modern C++, they should not be wasting their time on old-style C formatting.
– Sam Varshavchik
Nov 23 '18 at 2:50
related: stackoverflow.com/q/150543/1132334
– dlatikay
Nov 23 '18 at 2:50
This also creates a pretty glaring security vulnerability.
– Peter Ruderman
Nov 23 '18 at 2:52
@PeterRuderman, the security vulnerability is negligible as it is for local logging and not for public consumption.
– Adrian
Nov 23 '18 at 2:55
1
It is true that streams have higher overhead than C-style stdio formatting. However, with modern, multi-Ghz CPUs, this only becomes an issue when generating huge amounts of output. Any difference in "throughput" between streams and C-style stdio formatting is mostly academic, otherwise. And, with C++ streams you get type-safety. The best way to avoid writings bugs is to make it logically impossible to create them; and type-safety makes many classes of bugs logically impossible.
– Sam Varshavchik
Nov 23 '18 at 3:39
|
show 11 more comments
Neither.snprintf()
is prehistoric C. Modern C++ code uses the streams library, that implements formatted output in a fundamentally different way. If someone's intent is to learn modern C++, they should not be wasting their time on old-style C formatting.
– Sam Varshavchik
Nov 23 '18 at 2:50
related: stackoverflow.com/q/150543/1132334
– dlatikay
Nov 23 '18 at 2:50
This also creates a pretty glaring security vulnerability.
– Peter Ruderman
Nov 23 '18 at 2:52
@PeterRuderman, the security vulnerability is negligible as it is for local logging and not for public consumption.
– Adrian
Nov 23 '18 at 2:55
1
It is true that streams have higher overhead than C-style stdio formatting. However, with modern, multi-Ghz CPUs, this only becomes an issue when generating huge amounts of output. Any difference in "throughput" between streams and C-style stdio formatting is mostly academic, otherwise. And, with C++ streams you get type-safety. The best way to avoid writings bugs is to make it logically impossible to create them; and type-safety makes many classes of bugs logically impossible.
– Sam Varshavchik
Nov 23 '18 at 3:39
Neither.
snprintf()
is prehistoric C. Modern C++ code uses the streams library, that implements formatted output in a fundamentally different way. If someone's intent is to learn modern C++, they should not be wasting their time on old-style C formatting.– Sam Varshavchik
Nov 23 '18 at 2:50
Neither.
snprintf()
is prehistoric C. Modern C++ code uses the streams library, that implements formatted output in a fundamentally different way. If someone's intent is to learn modern C++, they should not be wasting their time on old-style C formatting.– Sam Varshavchik
Nov 23 '18 at 2:50
related: stackoverflow.com/q/150543/1132334
– dlatikay
Nov 23 '18 at 2:50
related: stackoverflow.com/q/150543/1132334
– dlatikay
Nov 23 '18 at 2:50
This also creates a pretty glaring security vulnerability.
– Peter Ruderman
Nov 23 '18 at 2:52
This also creates a pretty glaring security vulnerability.
– Peter Ruderman
Nov 23 '18 at 2:52
@PeterRuderman, the security vulnerability is negligible as it is for local logging and not for public consumption.
– Adrian
Nov 23 '18 at 2:55
@PeterRuderman, the security vulnerability is negligible as it is for local logging and not for public consumption.
– Adrian
Nov 23 '18 at 2:55
1
1
It is true that streams have higher overhead than C-style stdio formatting. However, with modern, multi-Ghz CPUs, this only becomes an issue when generating huge amounts of output. Any difference in "throughput" between streams and C-style stdio formatting is mostly academic, otherwise. And, with C++ streams you get type-safety. The best way to avoid writings bugs is to make it logically impossible to create them; and type-safety makes many classes of bugs logically impossible.
– Sam Varshavchik
Nov 23 '18 at 3:39
It is true that streams have higher overhead than C-style stdio formatting. However, with modern, multi-Ghz CPUs, this only becomes an issue when generating huge amounts of output. Any difference in "throughput" between streams and C-style stdio formatting is mostly academic, otherwise. And, with C++ streams you get type-safety. The best way to avoid writings bugs is to make it logically impossible to create them; and type-safety makes many classes of bugs logically impossible.
– Sam Varshavchik
Nov 23 '18 at 3:39
|
show 11 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440070%2fis-there-a-way-to-populate-an-ellipses-parameter-programmatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440070%2fis-there-a-way-to-populate-an-ellipses-parameter-programmatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Neither.
snprintf()
is prehistoric C. Modern C++ code uses the streams library, that implements formatted output in a fundamentally different way. If someone's intent is to learn modern C++, they should not be wasting their time on old-style C formatting.– Sam Varshavchik
Nov 23 '18 at 2:50
related: stackoverflow.com/q/150543/1132334
– dlatikay
Nov 23 '18 at 2:50
This also creates a pretty glaring security vulnerability.
– Peter Ruderman
Nov 23 '18 at 2:52
@PeterRuderman, the security vulnerability is negligible as it is for local logging and not for public consumption.
– Adrian
Nov 23 '18 at 2:55
1
It is true that streams have higher overhead than C-style stdio formatting. However, with modern, multi-Ghz CPUs, this only becomes an issue when generating huge amounts of output. Any difference in "throughput" between streams and C-style stdio formatting is mostly academic, otherwise. And, with C++ streams you get type-safety. The best way to avoid writings bugs is to make it logically impossible to create them; and type-safety makes many classes of bugs logically impossible.
– Sam Varshavchik
Nov 23 '18 at 3:39