1

I need a create a specific type of file in OS X. It needs resources in a specific way. Currently, the only way I can find to do this is in AppleScript with an OSAX. This is slow, about 1 second round trip to run, since the OSAX must open, load, do it's job, and quit. I have explored doing it in C, but that would be a last resort, as there always seems to be issues building apps out to make them work across multiple machines.

I was thinking, perhaps perl, or ideally bash could pull it off, but I am not 100% sure. The specs of what I need to do are as follows:

  • Create a text file, formatted as an email message (RFC 822/RFC 2822 format).

  • Text files must have an 'STR ' resource ID 8192 with an email address (will be used as the SMTP MAIL FROM address) and an 'STR#' resource ID 8192 with the recipient addresses (will be used as the SMTP RCPT TO addresses).

  • The text file should have CRLF as the line endings, and a 'BODY' resource ID 8192 should be added.

  • The 'BODY' resource should contain a 4 byte value, '822 ' for an unspecified body type, '7BIT' for 7-bit data, '8BIT' for 8-bit data, and 'BINM' for binary data.

Of course, the text file creation parts are simple, but stuffing those 'STR ' resources in has me stumped.

4

2 回答 2

1

你看过 REALbasic 吗?这使得编写这样的东西比 C 容易得多。不过,您不会免费获得它。

否则,请详细说明您可以使用哪些语言。您说的是您正在分发的应用程序-该应用程序的工作是否只是突然创建此文件?

另外,我不理解您对 C 和“构建应用程序以使它们在多台机器上工作”的问题。

于 2008-12-07T09:23:36.587 回答
0

yes, Real Basic can do this. In a nutshell, I use an oddball email server, and in order for it to take an email from the command line, I have to build a text file in a certain way, then move it to a certain folder, and the email will be delivered. The developer seems to like the resource forks, and that probably will not change.

I can currently do this with an OSAX in applescript, at the expense of only 1 message per second being created. Real Basic is going to be about the same.

As for C, I wrote a small command line app once, my first app, all it did was read the first few bytes of a file, convert some endianess values around, and return a integer. I had issues distributing it, since it would need to be built out on each platform. That is my only experience with C.

Yes, this apps job would only be to create this file. I know php really well, perl enough to get by at least reading it and editing it. Basically, I have fiddled in scripting languages for the better part of 10 years.

I imagine using this script like this: ./sendemail -f me@example.com < path/to/rfc822/email.txt

Thanks for any pointers.

于 2008-12-09T04:21:15.463 回答