-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the functionality of Preserved Comments in cupsd.conf when cups… #640
base: master
Are you sure you want to change the base?
Changes from 2 commits
4d13be6
b9c57d1
ccf71a9
d999b0d
1c0ae05
d08c54f
0a6b3b3
d351867
d92236a
f241386
952fd3f
7470d73
d9c1986
04b6730
07e9450
5150a47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -459,6 +459,7 @@ cupsAdminSetServerSettings( | |
cups_option_t *cupsd_settings, /* New settings */ | ||
*setting; /* Current setting */ | ||
_cups_globals_t *cg = _cupsGlobals(); /* Global data */ | ||
int linenum_check; /* same linenumber? */ | ||
|
||
|
||
/* | ||
|
@@ -667,6 +668,7 @@ cupsAdminSetServerSettings( | |
* Copy the old file to the new, making changes along the way... | ||
*/ | ||
|
||
linenum_check = 0; | ||
cupsd_num_settings = 0; | ||
in_admin_location = 0; | ||
in_cancel_job = 0; | ||
|
@@ -700,6 +702,16 @@ cupsAdminSetServerSettings( | |
|
||
while (cupsFileGetConf(cupsd, line, sizeof(line), &value, &linenum)) | ||
{ | ||
if (strchr(line, '#') != NULL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Several issues:
|
||
{ | ||
if(linenum == linenum_check+1) | ||
cupsFilePrintf(temp, "%s\n", line); | ||
else | ||
cupsFilePrintf(temp, "\n%s\n", line); | ||
linenum_check = linenum; | ||
} | ||
|
||
|
||
if ((!_cups_strcasecmp(line, "Port") || !_cups_strcasecmp(line, "Listen")) && | ||
(remote_admin >= 0 || remote_any >= 0 || share_printers >= 0)) | ||
{ | ||
|
@@ -774,8 +786,6 @@ cupsAdminSetServerSettings( | |
|
||
if (debug_logging) | ||
{ | ||
cupsFilePuts(temp, | ||
"# Show troubleshooting information in error_log.\n"); | ||
cupsFilePuts(temp, "LogLevel debug\n"); | ||
} | ||
else | ||
|
@@ -1058,7 +1068,11 @@ cupsAdminSetServerSettings( | |
cupsFilePrintf(temp, "%*s%s %s\n", indent, "", line, value); | ||
} | ||
else | ||
cupsFilePrintf(temp, "%*s%s\n", indent, "", line); | ||
{ | ||
if (strchr(line, '#') == NULL) | ||
cupsFilePrintf(temp, "%*s%s\n", indent, "", line); | ||
} | ||
|
||
} | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -769,6 +769,7 @@ cupsFileGetConf(cups_file_t *fp, /* I - CUPS file */ | |
ptr --; | ||
} | ||
|
||
return (buf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes behavior of public function, we mustn't do that. We need new internal function. |
||
*ptr = '\0'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will become a dead code if we return before that. Additionally I've realized we should deal with inline comments in case they appear (even though they are prohibited by cupsd.conf man page) in a way. So I propose:
So the block |
||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally you should review every cupsFilePut() below in Rephrase the comments mentioned in The code:
The default cupsd.conf.in:
so once you remove the cupsFilePut(), update the cupsd.conf.in to look like this f.e.:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@zdohnal for the above part what should be the comment that I need to write in conf/cupsd.conf.in ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example:
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ankit3002 We can't change the behavior of public function like below.
The idea was to have a new internal function, which has the same arguments as
cupsFileGetConf()
, but it will be able to return comments vialine
array. In general, it will be almost similar functionality ascupsFileGetConf()
, but it will return comment line (without leading and trailing whitespaces) as well as normal lines.