<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>postfix &#8211; Luxing Huang</title>
	<atom:link href="https://luxing.im/tag/postfix/feed/" rel="self" type="application/rss+xml" />
	<link>https://luxing.im</link>
	<description>Thoughs and things</description>
	<lastBuildDate>Mon, 29 Jul 2019 15:04:05 +0000</lastBuildDate>
	<language>en-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
<site xmlns="com-wordpress:feed-additions:1">58771605</site>	<item>
		<title>Make a secret copy of sent email in Postfix</title>
		<link>https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/</link>
					<comments>https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Sat, 06 Aug 2016 13:53:01 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[bcc]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[postfix]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=682</guid>

					<description><![CDATA[I have a business need. I need to send automatically generated email from a specific business address to my customers. Postfix does not help you to save it to &#8220;Sent&#8221; mailbox. Although I have mail logs telling me that emails have been sent to the correct email addresses but I really don&#8217;t know what is &#8230; <p class="link-more"><a href="https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/" class="more-link">Continue reading<span class="screen-reader-text"> "Make a secret copy of sent email in Postfix"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>I have a business need. I need to send automatically generated email from a specific business address to my customers. Postfix does not help you to save it to &#8220;Sent&#8221; mailbox. Although I have mail logs telling me that emails have been sent to the correct email addresses but I really don&#8217;t know what is being sent.</p>
<p>Because I setup my own mail server, this is going to be really easy. There is no need to change my business code to BCC a secret address, which is not very nice.</p>
<p><span id="more-682"></span></p>
<p>The steps are simple.</p>
<p>Add the line to /etc/postfix/main.cf</p>
<pre>sender_bcc_maps = hash:/etc/postfix/sender_bcc</pre>
<p>Write your <code>sender_bcc</code> file</p>
<pre>
business@address.com  bcc@example.com
</pre>
<p>Generate the hash.</p>
<pre>cd /etc/postfix
postmap sender_bcc
</pre>
<p>This will generate a .db file.</p>
<p>Reload postfix</p>
<pre>postfix reload</pre>
<p>Then all your email sent from <code>business@address.com</code> will automatically bcc&#8217;d to <code>bcc@example.com</code>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">682</post-id>	</item>
		<item>
		<title>Prefix expression conversion to Postfix and Infix</title>
		<link>https://luxing.im/prefix-expression-conversion-to-postfix-and-infix/</link>
					<comments>https://luxing.im/prefix-expression-conversion-to-postfix-and-infix/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Fri, 29 Nov 2013 15:20:40 +0000</pubDate>
				<category><![CDATA[Learning Notes]]></category>
		<category><![CDATA[assignment]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[infix]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[prefix]]></category>
		<guid isPermaLink="false">http://blog.luxing.im/?p=206</guid>

					<description><![CDATA[There has been a question related with prefix to infix/postfix expression on the latest assignment in C. I managed to solve this puzzle, the whole assignment is here and you can take a peek at (Question 2). The whole resolving idea has been basically expressed in Jim&#8217;s description, using a recursive way to build a &#8230; <p class="link-more"><a href="https://luxing.im/prefix-expression-conversion-to-postfix-and-infix/" class="more-link">Continue reading<span class="screen-reader-text"> "Prefix expression conversion to Postfix and Infix"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>There has been a question related with prefix to infix/postfix expression on the latest assignment in C. I managed to solve this puzzle, the whole assignment is <a href="http://socs.acadiau.ca/~jdiamond/comp2103/assignments/a12.pdf" target="_blank">here</a> and you can take a peek at (Question 2).<br />
<span id="more-206"></span><br />
The whole resolving idea has been basically expressed in Jim&#8217;s description, using a recursive way to build a tree, deal from left leaf to right leaf and printing out from bottom to top. This is code is my original piece, I might have a few presentation errors that not have matched with Jim&#8217;s requirements. Anyway, here is the whole code:</p>
<pre>
/*
 * File:        prefix.c
 * Author:      Luxing Huang
 * Date:        2013/11/24
 * Version:     1.0
 *
 * Purpose:     This programme will take in tokens from arguments or stdin to
 *              give back:
 *              1. postfix polish notation
 *              2. infix polish notation
 *              3. the result of the calculation (optional)
 *
 * Assumption:  User input will not exceed 256/2=128 chars.
 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>

#define LIMIT 257

int pos;

typedef struct expression_tree_node
{
    struct expression_tree_node *leftnode;
    struct expression_tree_node *rightnode;
    union
    {
        int32_t left;
        char leftop[4];
    } left;

    union
    {
        int32_t right;
        char rightop[4];
    } right;

    union
    {
        char topop[4]; 
        int32_t top;
    } top;

    bool left_done;
    bool right_done;
} *node_T;

/*
 * Name:        convert
 * Purpose:     Convert from prefix expression to infix and postfix expression.
 * Arguments:   prefixin, postout, infixout, leaf1
 * Returns:     nothing
 * Modifies:    postout, infixout
 */
void
convert(char *prefixin, char *postout, char *infixout, node_T leaf1)
{
    int ret;
    node_T leaf2 = malloc(sizeof(struct expression_tree_node)); 
    char *tmp = calloc(LIMIT, sizeof(char));
    char *postoutl = calloc(LIMIT, sizeof(char));
    char *postoutr = calloc(LIMIT, sizeof(char));
    char *infixoutl = calloc(LIMIT, sizeof(char));
    char *infixoutr = calloc(LIMIT, sizeof(char));

    pos = 0;

    if (tmp == NULL || postoutl == NULL || postoutr == NULL || infixoutl == NULL
            || infixoutr == NULL)
    {
        fprintf(stderr, "Unable to calloc.\n");
        exit(-1);
    }


    /* Scanning in the top operator */
    if (leaf1->top.topop == 0)
    {
        ret = sscanf(prefixin, "%s", leaf1->top.topop);
        if (ret == 0)
        {
            fprintf(stderr, "Invalid expression.\n");
            exit(-1);
        }
        pos+= 2;
    }

    /* Scanning left tree */
    ret = sscanf(prefixin, "%d", &leaf1->left.left);
    if (ret == 0)
    {
        ret = sscanf(prefixin, "%s", leaf1->left.leftop);
        if (ret == EOF)
        {
            fprintf(stderr, "Insufficient arguments!\n");
            exit(-1);
        }
        pos += 2;
        strncpy(leaf2->top.topop, leaf1->left.leftop, sizeof(int32_t));
        leaf1->leftnode = leaf2;
        convert(prefixin + pos, postoutl, infixoutl, leaf2);
        pos += 2;
    }
    else if (ret == EOF)
    {
        fprintf(stderr, "Insufficient arguments!\n");
        exit(-1);
    }
    else
    {
        pos += 2;
        leaf1->left_done = true;
    }

    /* Scanning Right tree */
    ret = sscanf(prefixin + pos, "%d", &leaf1->right.right);
    if (ret == 0)
    {
        ret = sscanf(prefixin + pos, "%s", leaf1->right.rightop);
        if (ret == EOF)
        {
            fprintf(stderr, "Insufficient arguments!\n");
            exit(-1);
        }
        pos += 2;
        strncpy(leaf2->top.topop, leaf1->right.rightop, sizeof(int32_t));
        leaf1->rightnode = leaf2;
        convert(prefixin + pos, postoutr, infixoutr, leaf2);
        pos += 2;
    }
    else if (ret == EOF)
    {
        fprintf(stderr, "Insufficient arguments!\n");
        exit(-1);
    }
    else
    {
        leaf1->right_done = true;
        pos += 2;
    }

    /* Setting up Output */
    if (leaf1->left_done == true)
    {
        if (leaf1->right_done == true)
        {
            sprintf(tmp, "%d %d %s ", leaf1->left.left, leaf1->right.right,
                    leaf1->top.topop);
            strncpy(postout, tmp, LIMIT);
            sprintf(tmp, "(%d %s %d)", leaf1->left.left, leaf1->top.topop,
                    leaf1->right.right);
            strncpy(infixout, tmp, LIMIT);
        }
        else
        {
            sprintf(tmp, "%d %s %s", leaf1->left.left, postoutr,
                    leaf1->top.topop);
            strncpy(postout, tmp, LIMIT);
            sprintf(tmp, "(%d %s %s)", leaf1->left.left, leaf1->top.topop,
                    infixoutr);
            strncpy(infixout, tmp, LIMIT);
        }
    }
    else
    {
        if (leaf1->right_done == true)
        {
            sprintf(tmp, "%s %d %s", postoutl, leaf1->right.right,
                    leaf1->top.topop);
            strncpy(postout, tmp, LIMIT);
            sprintf(tmp, "(%s %s %d)", infixoutl, leaf1->top.topop, 
                    leaf1->right.right);
            strncpy(infixout, tmp, LIMIT);
        }
        else 
        {
            sprintf(tmp, "%s %s %s", postout, postout, leaf1->top.topop);
            strncpy(postout, tmp, LIMIT);
            sprintf(tmp, "(%s %s %s)", infixout, leaf1->top.topop, infixout);
            strncpy(infixout, tmp, LIMIT);
        }
    }
}

int
main(int argc, char *argv[])
{
    char *prefixin = calloc(LIMIT,  sizeof(char));
    char *postout = calloc(LIMIT,  sizeof(char));
    char *infout = calloc(LIMIT,  sizeof(char));
    char arguments[] = "echo '";
    char bc[] = "' | bc ";
    node_T start_of_tree;
    start_of_tree = malloc(sizeof(struct expression_tree_node));

    if (prefixin == NULL || postout == NULL || infout == NULL || 
        start_of_tree == NULL)
    {
        fprintf(stderr, "Unable to malloc.\n");
        return EXIT_FAILURE;
    }
    int i, ret, count;
    count = 2;

    if (argc == 1)
    {
        if (isatty(fileno(stdin)))
        {
            printf("Please enter your expression: ");
        }
        fgets(prefixin, LIMIT, stdin);
    }
    else
    {
        for (i = 1; i < argc; i++)
        {
            strcat(prefixin, argv[i]);
            strcat(prefixin, " ");
        }
    }

    ret = sscanf(prefixin, "%d", &#038;start_of_tree->top.top);
    if (ret == 1)
    {
        printf("Postfix: %d\n", start_of_tree->top.top);
        printf("Infix:   (%d)\n", start_of_tree->top.top);
        printf("Result:  %d\n", start_of_tree->top.top);
        return EXIT_SUCCESS;
    }
    else
    {
        ret = sscanf(prefixin, "%s", start_of_tree->top.topop);
        if (ret == 0)
        {
            fprintf(stderr, "Invalid expression!\n");
            return EXIT_FAILURE;
        }
    }

    convert(prefixin + count, postout, infout, start_of_tree);

    printf("Postfix: %s\n", postout);
    printf("Infix:   %s\n", infout);
    printf("Result:  ");
    fflush(stdout);

    strcat(arguments, infout);
    strcat(arguments, bc);
    system(arguments);
    return EXIT_SUCCESS;
}
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/prefix-expression-conversion-to-postfix-and-infix/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">206</post-id>	</item>
	</channel>
</rss>
