Closed metabiswadeep closed 1 year ago
I have added some comments.
Make always sure that memory you allocate gets freed again, especially with a Printer Application as a permanently running daemion you will accumulate lost memory (memory leak).
Also initialize your variables appropriately. A CUPS array needs to get created with some flavor of cupsArrayNew
before starting with cupsArrayAdd()
. Also the report pointer needs to be initialized to NULL, to tell ppdTest()
to create the array.
Also make sure that the reports of ppdTest()
come out nicely in the browser. I recommend to, in case of more than one PPD uploaded by the user at once, add all new PPDs to file_array
and do a single run of ppdTest()
to get one report for all PPDs. Then you display the report the same way the license of the proprietary HP plugin is displayed in the HPLIP Printer Application.
@tillkamppeter I am unable to test it in the browser as errors unrelated to the change in this code are coming while trying to compile the code.
The utility is working as expected now.
Looks generally OK, the issues I have reported are fixed. I have tested it now by quickly correcting libppd as I suggested in OpenPrinting/libppd#12 .
Could you only do one tiny change? When you are adding the report of ppdTest()
for a failed PPD case, please add one blank line before it, so that one sees more easily to which PPD it belongs.
You have now
Uploaded a.ppd
b.ppd: FAIL
XXX
YYY
Uploaded b.ppd
It would look better like that:
Uploaded a.ppd
b.ppd: FAIL
XXX
YYY
Uploaded b.ppd
Now it looks somehow strange:
Uploaded:lj1000.ppd: OK
lj4050.ppd: WARNING: Options which will possibly not work: Use Straight Paper Path
/var/lib/legacy-printer-app/ppd/lxS300-S400.ppd:
FAIL
**FAIL** Missing cupsFilter file "/usr/local/lexmark/v3/bin/printfilter".
WARN Size "LetterBL" should be the Adobe standard name "229.31x305.51mm".
WARN Size "LetterBA" should be the Adobe standard name "8.5x110".
WARN Size "LegalBL" should be the Adobe standard name "9x15".
WARN Size "A4BL" should be the Adobe standard name "217.38x323.07mm".
WARN Size "A4BA" should be the Adobe standard name "209.97x2970.04mm".
WARN Size "A5BL" should be the Adobe standard name "155.43x236.08mm".
WARN Size "B5JIS" should be the Adobe standard name "B5".
WARN Size "B5JISBL" should be the Adobe standard name "189.51x283.07mm".
WARN Size "Envelope10" should be the Adobe standard name "Env10".
WARN Size "Envelope9" should be the Adobe standard name "Env100.89x225.43mm".
WARN Size "Envelope734" should be the Adobe standard name "EnvMonarch".
WARN Size "Envelope634" should be the Adobe standard name "EnvPersonal".
WARN Size "EnvelopeA2" should be the Adobe standard name "EnvA2".
WARN Size "EnvelopeB5" should be the Adobe standard name "EnvISOB5".
WARN Size "EnvelopeC6" should be "114x162mm".
WARN Size "EnvelopeDL" should be the Adobe standard name "EnvDL".
WARN Size "EnvelopeChokei3" should be the Adobe standard name "EnvChou3".
WARN Size "EnvelopeChokei4" should be the Adobe standard name "EnvChou4".
WARN Size "EnvelopeChokei40" should be the Adobe standard name "EnvChou40".
WARN Size "EnvelopeKakugata3" should be the Adobe standard name "EnvKaku3".
WARN Size "EnvelopeKakugata4" should be the Adobe standard name "EnvKaku4".
WARN Size "EnvelopeKakugata5" should be the Adobe standard name "EnvKaku5".
WARN Size "EnvelopeKakugata6" should be the Adobe standard name "EnvC5".
WARN Size "Card3x5" should be the Adobe standard name "3x5".
WARN Size "CardA6" should be the Adobe standard name "A6".
WARN Size "CardA6BL" should be the Adobe standard name "112.47x174.06mm".
WARN Size "PostcardHagaki" should be the Adobe standard name "Postcard".
WARN Size "PostcardHagakiBL" should be the Adobe standard name "107.49x174.06mm".
WARN Size "Photo312x5" should be the Adobe standard name "3.5x5".
WARN Size "Photo312x5BL" should be the Adobe standard name "96.33x153.11mm".
WARN Size "4x6BL" should be the Adobe standard name "109.08x178.51mm".
WARN Size "4x8BL" should be the Adobe standard name "109.08x229.31mm".
WARN Size "Photo5x7" should be the Adobe standard name "5x7".
WARN Size "Photo5x7BL" should be the Adobe standard name "134.48x203.91mm".
WARN Size "PhotoL" should be the Adobe standard name "3.5x5".
WARN Size "PhotoLBL" should be the Adobe standard name "96.52x153.11mm".
WARN Size "Photo2L" should be the Adobe standard name "5x7".
WARN Size "Photo2LBL" should be the Adobe standard name "134.48x203.91mm".
WARN Size "10x15cm" should be "102x153mm".
WARN Size "10x15cmBL" should be the Adobe standard name "109.08x178.86mm".
WARN Size "13x18cm" should be "127x178mm".
WARN Size "13x18cmBL" should be the Adobe standard name "134.48x204.33mm".
WARN Size "10x20cm" should be the Adobe standard name "4x8".
WARN Size "10x20cmBL" should be the Adobe standard name "109.08x229.31mm".
WARN PCFileName longer than 8.3 in violation of PPD spec.
REF: Pages 61-62, section 5.3.
lxS300-S400.ppd: OK
Printer.ppd: OK
Could you test selecting your "bad" PPD plus several "good" PPDs at once?
Ideally when loading a PPD is just OK, the x.ppd: OK
lines should come without blank lines inbetween, but if a PPD causes some warning, failure report or other extra info, everything about it should be separated by a blank line before and after, so that one sees that the /var/lib/legacy-printer-app/ppd/lxS300-S400.ppd:
, FAIL ...
, and lxS300-S400.ppd: OK
belong together.
Did you actually try out your changes? Now the output looks even more strange, a lot of space before each line, but no space before the /var/lib/legacy-printer-app/ppd/lxS300-S400.ppd:
line:
Uploaded:Printer.ppd: OK
lj4050.ppd: WARNING: Options which will possibly not work: Use Straight Paper Path
lj1000.ppd: OK
/var/lib/legacy-printer-app/ppd/lxS300-S400.ppd:
FAIL
**FAIL** Missing cupsFilter file "/usr/local/lexmark/v3/bin/printfilter".
WARN Size "LetterBL" should be the Adobe standard name "229.31x305.51mm".
WARN Size "LetterBA" should be the Adobe standard name "8.5x110".
WARN Size "LegalBL" should be the Adobe standard name "9x15".
WARN Size "A4BL" should be the Adobe standard name "217.38x323.07mm".
WARN Size "A4BA" should be the Adobe standard name "209.97x2970.04mm".
WARN Size "A5BL" should be the Adobe standard name "155.43x236.08mm".
WARN Size "B5JIS" should be the Adobe standard name "B5".
WARN Size "B5JISBL" should be the Adobe standard name "189.51x283.07mm".
WARN Size "Envelope10" should be the Adobe standard name "Env10".
WARN Size "Envelope9" should be the Adobe standard name "Env100.89x225.43mm".
WARN Size "Envelope734" should be the Adobe standard name "EnvMonarch".
WARN Size "Envelope634" should be the Adobe standard name "EnvPersonal".
WARN Size "EnvelopeA2" should be the Adobe standard name "EnvA2".
WARN Size "EnvelopeB5" should be the Adobe standard name "EnvISOB5".
WARN Size "EnvelopeC6" should be "114x162mm".
WARN Size "EnvelopeDL" should be the Adobe standard name "EnvDL".
WARN Size "EnvelopeChokei3" should be the Adobe standard name "EnvChou3".
WARN Size "EnvelopeChokei4" should be the Adobe standard name "EnvChou4".
WARN Size "EnvelopeChokei40" should be the Adobe standard name "EnvChou40".
WARN Size "EnvelopeKakugata3" should be the Adobe standard name "EnvKaku3".
WARN Size "EnvelopeKakugata4" should be the Adobe standard name "EnvKaku4".
WARN Size "EnvelopeKakugata5" should be the Adobe standard name "EnvKaku5".
WARN Size "EnvelopeKakugata6" should be the Adobe standard name "EnvC5".
WARN Size "Card3x5" should be the Adobe standard name "3x5".
WARN Size "CardA6" should be the Adobe standard name "A6".
WARN Size "CardA6BL" should be the Adobe standard name "112.47x174.06mm".
WARN Size "PostcardHagaki" should be the Adobe standard name "Postcard".
WARN Size "PostcardHagakiBL" should be the Adobe standard name "107.49x174.06mm".
WARN Size "Photo312x5" should be the Adobe standard name "3.5x5".
WARN Size "Photo312x5BL" should be the Adobe standard name "96.33x153.11mm".
WARN Size "4x6BL" should be the Adobe standard name "109.08x178.51mm".
WARN Size "4x8BL" should be the Adobe standard name "109.08x229.31mm".
WARN Size "Photo5x7" should be the Adobe standard name "5x7".
WARN Size "Photo5x7BL" should be the Adobe standard name "134.48x203.91mm".
WARN Size "PhotoL" should be the Adobe standard name "3.5x5".
WARN Size "PhotoLBL" should be the Adobe standard name "96.52x153.11mm".
WARN Size "Photo2L" should be the Adobe standard name "5x7".
WARN Size "Photo2LBL" should be the Adobe standard name "134.48x203.91mm".
WARN Size "10x15cm" should be "102x153mm".
WARN Size "10x15cmBL" should be the Adobe standard name "109.08x178.86mm".
WARN Size "13x18cm" should be "127x178mm".
WARN Size "13x18cmBL" should be the Adobe standard name "134.48x204.33mm".
WARN Size "10x20cm" should be the Adobe standard name "4x8".
WARN Size "10x20cmBL" should be the Adobe standard name "109.08x229.31mm".
WARN PCFileName longer than 8.3 in violation of PPD spec.
REF: Pages 61-62, section 5.3.
lxS300-S400.ppd: OK
C43x.ppd: OK
Did you actually try out your changes? Now the output looks even more strange, a lot of space before each line, but no space before the
/var/lib/legacy-printer-app/ppd/lxS300-S400.ppd:
line:Uploaded:Printer.ppd: OK lj4050.ppd: WARNING: Options which will possibly not work: Use Straight Paper Path lj1000.ppd: OK /var/lib/legacy-printer-app/ppd/lxS300-S400.ppd: FAIL **FAIL** Missing cupsFilter file "/usr/local/lexmark/v3/bin/printfilter". WARN Size "LetterBL" should be the Adobe standard name "229.31x305.51mm". WARN Size "LetterBA" should be the Adobe standard name "8.5x110". WARN Size "LegalBL" should be the Adobe standard name "9x15". WARN Size "A4BL" should be the Adobe standard name "217.38x323.07mm". WARN Size "A4BA" should be the Adobe standard name "209.97x2970.04mm". WARN Size "A5BL" should be the Adobe standard name "155.43x236.08mm". WARN Size "B5JIS" should be the Adobe standard name "B5". WARN Size "B5JISBL" should be the Adobe standard name "189.51x283.07mm". WARN Size "Envelope10" should be the Adobe standard name "Env10". WARN Size "Envelope9" should be the Adobe standard name "Env100.89x225.43mm". WARN Size "Envelope734" should be the Adobe standard name "EnvMonarch". WARN Size "Envelope634" should be the Adobe standard name "EnvPersonal". WARN Size "EnvelopeA2" should be the Adobe standard name "EnvA2". WARN Size "EnvelopeB5" should be the Adobe standard name "EnvISOB5". WARN Size "EnvelopeC6" should be "114x162mm". WARN Size "EnvelopeDL" should be the Adobe standard name "EnvDL". WARN Size "EnvelopeChokei3" should be the Adobe standard name "EnvChou3". WARN Size "EnvelopeChokei4" should be the Adobe standard name "EnvChou4". WARN Size "EnvelopeChokei40" should be the Adobe standard name "EnvChou40". WARN Size "EnvelopeKakugata3" should be the Adobe standard name "EnvKaku3". WARN Size "EnvelopeKakugata4" should be the Adobe standard name "EnvKaku4". WARN Size "EnvelopeKakugata5" should be the Adobe standard name "EnvKaku5". WARN Size "EnvelopeKakugata6" should be the Adobe standard name "EnvC5". WARN Size "Card3x5" should be the Adobe standard name "3x5". WARN Size "CardA6" should be the Adobe standard name "A6". WARN Size "CardA6BL" should be the Adobe standard name "112.47x174.06mm". WARN Size "PostcardHagaki" should be the Adobe standard name "Postcard". WARN Size "PostcardHagakiBL" should be the Adobe standard name "107.49x174.06mm". WARN Size "Photo312x5" should be the Adobe standard name "3.5x5". WARN Size "Photo312x5BL" should be the Adobe standard name "96.33x153.11mm". WARN Size "4x6BL" should be the Adobe standard name "109.08x178.51mm". WARN Size "4x8BL" should be the Adobe standard name "109.08x229.31mm". WARN Size "Photo5x7" should be the Adobe standard name "5x7". WARN Size "Photo5x7BL" should be the Adobe standard name "134.48x203.91mm". WARN Size "PhotoL" should be the Adobe standard name "3.5x5". WARN Size "PhotoLBL" should be the Adobe standard name "96.52x153.11mm". WARN Size "Photo2L" should be the Adobe standard name "5x7". WARN Size "Photo2LBL" should be the Adobe standard name "134.48x203.91mm". WARN Size "10x15cm" should be "102x153mm". WARN Size "10x15cmBL" should be the Adobe standard name "109.08x178.86mm". WARN Size "13x18cm" should be "127x178mm". WARN Size "13x18cmBL" should be the Adobe standard name "134.48x204.33mm". WARN Size "10x20cm" should be the Adobe standard name "4x8". WARN Size "10x20cmBL" should be the Adobe standard name "109.08x229.31mm". WARN PCFileName longer than 8.3 in violation of PPD spec. REF: Pages 61-62, section 5.3. lxS300-S400.ppd: OK C43x.ppd: OK
I did try out the changes. I noticed that there were blank lines coming before the data of each failed ppd but did not see that the spacing before the path name had decreased. I'll fix it.
Is this output okay?
Uploaded:c43x.ppd: OK
cnadv400x1g.ppd: WARNING: Options which will possibly not work: Collated
/var/lib/ps-printer-app/ppd/lxS300-S400.ppd:
FAIL
**FAIL** Missing cupsFilter file "/usr/local/lexmark/v3/bin/printfilter".
WARN Size "LetterBL" should be the Adobe standard name "229.31x305.51mm".
WARN Size "LetterBA" should be the Adobe standard name "8.5x110".
WARN Size "LegalBL" should be the Adobe standard name "9x15".
WARN Size "A4BL" should be the Adobe standard name "217.38x323.07mm".
WARN Size "A4BA" should be the Adobe standard name "209.97x2970.04mm".
WARN Size "A5BL" should be the Adobe standard name "155.43x236.08mm".
WARN Size "B5JIS" should be the Adobe standard name "B5".
WARN Size "B5JISBL" should be the Adobe standard name "189.51x283.07mm".
WARN Size "Envelope10" should be the Adobe standard name "Env10".
WARN Size "Envelope9" should be the Adobe standard name "Env100.89x225.43mm".
WARN Size "Envelope734" should be the Adobe standard name "EnvMonarch".
WARN Size "Envelope634" should be the Adobe standard name "EnvPersonal".
WARN Size "EnvelopeA2" should be the Adobe standard name "EnvA2".
WARN Size "EnvelopeB5" should be the Adobe standard name "EnvISOB5".
WARN Size "EnvelopeC6" should be "114x162mm".
WARN Size "EnvelopeDL" should be the Adobe standard name "EnvDL".
WARN Size "EnvelopeChokei3" should be the Adobe standard name "EnvChou3".
WARN Size "EnvelopeChokei4" should be the Adobe standard name "EnvChou4".
WARN Size "EnvelopeChokei40" should be the Adobe standard name "EnvChou40".
WARN Size "EnvelopeKakugata3" should be the Adobe standard name "EnvKaku3".
WARN Size "EnvelopeKakugata4" should be the Adobe standard name "EnvKaku4".
WARN Size "EnvelopeKakugata5" should be the Adobe standard name "EnvKaku5".
WARN Size "EnvelopeKakugata6" should be the Adobe standard name "EnvC5".
WARN Size "Card3x5" should be the Adobe standard name "3x5".
WARN Size "CardA6" should be the Adobe standard name "A6".
WARN Size "CardA6BL" should be the Adobe standard name "112.47x174.06mm".
WARN Size "PostcardHagaki" should be the Adobe standard name "Postcard".
WARN Size "PostcardHagakiBL" should be the Adobe standard name "107.49x174.06mm".
WARN Size "Photo312x5" should be the Adobe standard name "3.5x5".
WARN Size "Photo312x5BL" should be the Adobe standard name "96.33x153.11mm".
WARN Size "4x6BL" should be the Adobe standard name "109.08x178.51mm".
WARN Size "4x8BL" should be the Adobe standard name "109.08x229.31mm".
WARN Size "Photo5x7" should be the Adobe standard name "5x7".
WARN Size "Photo5x7BL" should be the Adobe standard name "134.48x203.91mm".
WARN Size "PhotoL" should be the Adobe standard name "3.5x5".
WARN Size "PhotoLBL" should be the Adobe standard name "96.52x153.11mm".
WARN Size "Photo2L" should be the Adobe standard name "5x7".
WARN Size "Photo2LBL" should be the Adobe standard name "134.48x203.91mm".
WARN Size "10x15cm" should be "102x153mm".
WARN Size "10x15cmBL" should be the Adobe standard name "109.08x178.86mm".
WARN Size "13x18cm" should be "127x178mm".
WARN Size "13x18cmBL" should be the Adobe standard name "134.48x204.33mm".
WARN Size "10x20cm" should be the Adobe standard name "4x8".
WARN Size "10x20cmBL" should be the Adobe standard name "109.08x229.31mm".
WARN PCFileName longer than 8.3 in violation of PPD spec.
REF: Pages 61-62, section 5.3.
lxS300-S400.ppd: OK
/var/lib/ps-printer-app/ppd/secc3900_bad.ppd:
FAIL
**FAIL** Bad Product - not "(string)".
REF: Page 62, section 5.3.
**FAIL** Missing option CustomPageSize in UIConstraints "*InputSlot Tray3 *CustomPageSize ".
**FAIL** Missing option CustomPageSize in UIConstraints "*CustomPageSize *InputSlot Tray3".
WARN Non-Windows PPD files should use lines ending with only LF, not CR LF.
WARN Size "8.125x13.25" should be the Adobe standard name "206.38x336.55mm".
WARN Size "B6" should be the Adobe standard name "127.71x180.62mm".
WARN Size "A4Plus" should be the Adobe standard name "Folio".
WARN Size "Foolscap" should be the Adobe standard name "8x13".
WARN Size "UKQuarto" should be the Adobe standard name "8x10".
WARN Size "GLetter" should be the Adobe standard name "8x10.5".
WARN Size "GLegal" should be "216x330mm".
WARN Size "Com10" should be the Adobe standard name "Env10".
WARN Size "JPostcard" should be the Adobe standard name "Postcard".
WARN Size "16K" should be the Adobe standard name "195.09x269.88mm".
WARN Size "Kai16" should be the Adobe standard name "184.86x260mm".
WARN Size "Kai32" should be the Adobe standard name "130.18x184.86mm".
WARN DefaultUseHWMargins has no corresponding options.
WARN DefaultOutputBin has no corresponding options.
secc3900_bad.ppd: OK
cnadv400x1g.ppd: WARNING: Options which will possibly not work: Collated
OK, this looks correct now.
@tillkamppeter Are there any further modifications necessary for this?
Fix to issue 12 of ps-printer-app
Now uploading a bad PPD to the web interface of ps-printer-app will raise warnings.