• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to pass filenames to system( ) ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pass filenames to system( ) ?


  • Subject: Re: How to pass filenames to system( ) ?
  • From: Patrick Stadelmann <email@hidden>
  • Date: Wed, 03 Mar 2010 14:34:38 +0100

Quinn wrote:

> If you have to use system(), you will run into various gotchas like
> the one you described.  You will have to parse each path and apply
> quoting.  AFAIK there's no C-language routine to do this, but it's
> not too hard to do.  I know I've written this code before, but I
> wasn't able to unearth it, alas.  The basic idea is:
>
> 1. go through every byte of the string
>
> 2. if the byte is a reasonable value, pass it through unquoted
>
> 3. otherwise quote the byte by prefixing it with slosh ('\')
>
> The exact definition of reasonable is tricky but, to be on the safe
> side, you can just say that the alphanumerics and underscore are
> reasonable, and everything else is not.
>
> Oh, cool, I finally managed to track down my code.

Thanks for your answer. In the meantime, I tried escaping every
single character, and it seems to also work. Simpler, but less
memory efficient.

I didn't choose to use system(), I'm trying to modify the cups-pdf
tool (a virtual printer that enable batch printing to PDF, without
going through the print dialog), which use only portable functions.
The call to system() is used to invoke the .ps to .pdf interpreter,
something that could probably also be done differently on Mac OS X.

Thanks again,

Patrick
--
Patrick Stadelmann <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to pass filenames to system( ) ?
      • From: Gregg Wonderly <email@hidden>
    • Re: How to pass filenames to system( ) ?
      • From: Quinn <email@hidden>
References: 
 >How to pass filenames to system( ) ? (From: Patrick Stadelmann <email@hidden>)
 >Re: How to pass filenames to system( ) ? (From: Quinn <email@hidden>)

  • Prev by Date: Re: How to pass filenames to system( ) ?
  • Next by Date: Re: How to pass filenames to system( ) ?
  • Previous by thread: Re: How to pass filenames to system( ) ?
  • Next by thread: Re: How to pass filenames to system( ) ?
  • Index(es):
    • Date
    • Thread