コード例 #1
0
ファイル: smsc_http.c プロジェクト: Jayriq/kannel-gateway
static void kannel_parse_reply(SMSCConn *conn, Msg *msg, int status,
			       List *headers, Octstr *body)
{
    /* Test on three cases:
     * 1. an smsbox reply of an remote kannel instance
     * 2. an smsc_http response (if used for MT to MO looping)
     * 3. an smsbox reply of partly successful sendings */
    if ((status == HTTP_OK || status == HTTP_ACCEPTED)
        && (octstr_case_compare(body, octstr_imm("0: Accepted for delivery")) == 0 ||
            octstr_case_compare(body, octstr_imm("Sent.")) == 0 ||
            octstr_case_compare(body, octstr_imm("Ok.")) == 0 ||
            octstr_ncompare(body, octstr_imm("Result: OK"),10) == 0)) {
        char id[UUID_STR_LEN + 1];
        Octstr *mid;

        /* create Octstr from UUID */  
        uuid_unparse(msg->sms.id, id);
        mid = octstr_create(id); 
    
        /* add to our own DLR storage */               
        if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
            dlr_add(conn->id, mid, msg, 0);

        octstr_destroy(mid);            
            
        bb_smscconn_sent(conn, msg, NULL);
    } else {
        bb_smscconn_send_failed(conn, msg,
	            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body));
    }
}
コード例 #2
0
ファイル: timestamp.c プロジェクト: armic/erpts
static int remove_prefix(Octstr *os, Octstr *prefix)
{
    if (octstr_ncompare(os, prefix, octstr_len(prefix)) != 0)
    	return -1;
    octstr_delete(os, 0, octstr_len(prefix));
    return 0;
}
コード例 #3
0
ファイル: wap_push_pap_mime.c プロジェクト: Phonebooth/kannel
static long parse_close_delimiter(Octstr *close_delimiter, Octstr *mime_content,
                                  long pos)
{
    if (octstr_ncompare(close_delimiter, mime_content, 
                        octstr_len(close_delimiter)) != 0)
        return -1;
    pos += octstr_len(close_delimiter);

    return pos;
}
コード例 #4
0
ファイル: dlr_spool.c プロジェクト: tphipps/kannel
static Octstr *get_msg_filename(const Octstr *dir_s, const Octstr *hash, const Octstr *dst)
{
	Octstr *ret;
    DIR *dir;
    struct dirent *ent;
    char *hash_cstr;

    if ((dir = opendir(octstr_get_cstr(dir_s))) == NULL) {
        error(errno, "Could not open directory `%s'", octstr_get_cstr(dir_s));
        return NULL;
    }

    hash_cstr = octstr_get_cstr(hash);
    while ((ent = readdir(dir)) != NULL) {
    	Octstr *fname = octstr_create((char*)ent->d_name);

    	if (octstr_ncompare(fname, hash, OUR_DIGEST_LEN) == 0) {
    		Octstr *addr;
    		long addr_len, pos;

    		/* this is a candidate */
    		if (dst == NULL)
    			goto found;

    		/* check for the destination address suffix part */
    		if ((addr_len = (octstr_len(fname) - OUR_DIGEST_LEN)) < 0 ||
    				(pos = (addr_len - octstr_len(dst))) < 0) {
    			octstr_destroy(fname);
    			continue;
    		}
    		addr = octstr_copy(fname, OUR_DIGEST_LEN, addr_len);

    		/* if not found, then bail out*/
    		if (octstr_search(addr, dst, pos) == -1) {
    			octstr_destroy(addr);
    			octstr_destroy(fname);
    			continue;
    		}
    		octstr_destroy(addr);
found:
			/* found it */
			closedir(dir);
			ret = octstr_format("%S/%S", dir_s, fname);
			octstr_destroy(fname);
			return ret;
    	}
    	octstr_destroy(fname);
    }
    closedir(dir);

    return NULL;
}
コード例 #5
0
ファイル: wap_push_si_compiler.c プロジェクト: pwhelan/kannel
/*
 * Tokenises an attribute, and in most cases, the start of its value (some-
 * times whole of it). Tokenisation is based on tables in si, chapters 9.3.2
 * and 9.3.3. 
 * Returns 0 when success, -1 when error.
 */
static int parse_attribute(xmlAttrPtr attr, simple_binary_t **sibxml)
{
    Octstr *name,
           *value,
           *valueos,
           *tokenized_date;
    unsigned char si_hex;
    size_t i,
           value_len;

    name = octstr_create((char *)attr->name);

    if (attr->children != NULL)
	value = create_octstr_from_node((char *)attr->children);
    else 
	value = NULL;

    if (value == NULL)
        goto error;

    i = 0;
    valueos = NULL;
    while (i < NUMBER_OF_ATTRIBUTES) {
        if (octstr_compare(name, octstr_imm(si_attributes[i].name)) == 0) {
	    if (si_attributes[i].value_part == NULL) {
	        break; 
            } else {
                value_len = octstr_len(valueos = 
                    octstr_imm(si_attributes[i].value_part));
	        if (octstr_ncompare(value, valueos, value_len) == 0) {
		    break;
                }
            }
        }
       ++i;
    }

    if (i == NUMBER_OF_ATTRIBUTES)
        goto error;

    tokenized_date = NULL;
    si_hex = si_attributes[i].token;
    if (action(si_hex)) {
        output_char(si_hex, sibxml);
    } else if (url(si_hex)) {
        output_char(si_hex, sibxml);
        octstr_delete(value, 0, octstr_len(valueos));
        parse_url_value(value, sibxml);
    } else if (date(si_hex)) {
        if ((tokenized_date = tokenize_date(value)) == NULL)
            goto error;
        output_char(si_hex, sibxml);
        output_octet_string(tokenized_date, sibxml);
    } else {
        output_char(si_hex, sibxml);
        parse_inline_string(value, sibxml);
    }  

    octstr_destroy(tokenized_date);
    octstr_destroy(name);
    octstr_destroy(value);
    return 0;

error:
    octstr_destroy(name);
    octstr_destroy(value);
    return -1;
}