示例#1
0
void 	my_layer_delete_all_control_shapes	(MyLayer *self) {
	/*
	GQueue *tmpQ;
	guint j, len;
	MyShape *shape;
	MyLayerPrivate* priv = MY_LAYER_GET_PRIVATE (self);
	my_debug ("delete all control shapes ...");
	tmpQ = g_queue_new();
	// 双队列实现删除
	g_queue_push_tail (priv->shapes, NULL);
	while (shape = g_queue_pop_head (priv->shapes)) {
		my_debug ("loop %u shape %#x", j, shape);
		if (MY_IS_CONTROL_SHAPE_RECT(shape)) {
			my_debug ("deleting control shape %#x", shape);
		} else {
			g_queue_push_tail (tmpQ, shape);
		}
	}
	g_queue_clear (priv->shapes);
	priv->shapes = tmpQ;
	my_debug ("delete all control shapes done.");
	*/
	
	GQueue *tmpQ;
	MyLayerPrivate* priv = MY_LAYER_GET_PRIVATE (self);
	my_debug ("deleting all control in shapes queue %#x ...", priv->shapes);
	my_debug ("deleteData function %#x ...", deleteData);
	
	tmpQ = my_util_delete_queue_element (priv->shapes, deleteData, NULL);
	g_queue_clear (priv->shapes);
	priv->shapes = tmpQ;
	
	my_debug ("after delete shapes count is %d", g_queue_get_length (tmpQ));
	my_debug ("deleting all control in shapes queue %#x done.", priv->shapes);
}
示例#2
0
MyShape *	my_layer_hit_shape		(MyLayer *self, gdouble x, gdouble y, gint selectWidth, ApplicationState *appState) {

	
	guint shapeCount, j;
	MyShape *shape;
	shapeCount = my_layer_shape_count (self);
	// check control shapes
	for (j = 0; j < shapeCount; j++) {
		shape = my_layer_peek_nth (self, j);
		if (shape->isControlShape) {
			if ( my_shape_is_chosen (shape, x, y, selectWidth, appState) ) {
				my_debug ("hit shape loop count: %d", j);
				my_debug ("hitted shape %#x", shape);
				return shape;
			}
		}
	}
	// check normal shapes
	for (j = shapeCount - 1; j >= 0; j--) {
		shape = my_layer_peek_nth (self, j);
		if (shape->isControlShape)
			break;
		if ( my_shape_is_chosen (shape, x, y, selectWidth, appState) ) {
			my_debug ("hit shape loop count: %d", j);
			my_debug ("hitted shape %#x", shape);
			return shape;
		}
	}
	return NULL;
}
示例#3
0
文件: logout.c 项目: Doap/transports
int jabber_close() {
	my_debug(0, "jabber: Zakonczenie transmisji!");
	close(jabber_server);
	my_debug(0, "jabber: Polaczenie zamkniete!");

	close(jabber_gniazdo);
	my_debug(0, "jabber: Gniazdo zamkniete!");
	return 0;
}
示例#4
0
//int generate_registry(){
int generate_registry(char *prov_type)
{
  
    PGresult* result = NULL;
    char sqlcmd[2048] = "";
    int num_rows, i;
    char buff[2048] ="";
        
    sprintf(sqlcmd,"SELECT devices.defaultuser, devices.secret, devices.host, devices.port, devices.regexten FROM public.devices WHERE devices.device_type = 'provider' AND register IS TRUE;");
  
    if (SHOW_SQL)
    {
        sprintf(buff,"SQL: %s\n",sqlcmd);
        my_debug(buff);
    }
    
    if (!(result = PQexec(conn, sqlcmd))) {
        my_debug("Errorrr");
        PQclear(result);
        return -1;
    }
    else // query succeeded, process any data returned by it
    {
        if ((num_rows = PQntuples(result)) < 1) {
            PQclear(result);
            return -1;
        }

        for (i = 0; i < num_rows; i++) 
        {
            sprintf(buff, "");
            sprintf(buff, "register => %s:%s@%s", PQgetvalue(result,i,0), PQgetvalue(result,i,1), PQgetvalue(result,i,2));

            //port
            if ((PQgetvalue(result,i,3)) && (strlen(PQgetvalue(result,i,3))) )
            {
                sprintf(buff, "%s:%s", buff, PQgetvalue(result,i,3));
            } 
            
            //extension
            if ((PQgetvalue(result,i,4)) && (strlen(PQgetvalue(result,i,4)) > 0) ){
                sprintf(buff, "%s/%s", buff, PQgetvalue(result,i,4));
            } 
          
            sprintf(buff, "%s\n", buff);    
            printf(buff);
            my_debug(buff);
        }
    }
         
    PQclear(result);

    return 0;
    
}
示例#5
0
void	my_layer_delete_shape_only (MyLayer *self, MyShape *shape) {

	my_debug ("deleting shape only ...");
	// 删除图形自己
	if (shape->isDeletable) {
		MyLayerPrivate* priv = MY_LAYER_GET_PRIVATE (self);
		g_queue_remove (priv->shapes, shape);
		if (shape == priv->selectedShape)
			priv->selectedShape = NULL;
	}
	my_debug ("deleting shape only done.");
}
示例#6
0
void	my_layer_clear		(MyLayer *self) {


	MyLayerPrivate* priv = MY_LAYER_GET_PRIVATE (self);
	g_queue_clear (priv->shapes);
	priv->selectedShape = NULL;
	my_debug ("clear layer done.");
}
示例#7
0
文件: users.c 项目: Doap/transports
int users_init() {
	DIR *katalog;
	struct dirent *pozycja;

	tt_user *user;
	int i;

	i = 0;
	if ((tt_users = (tt_user**)malloc((i+1)*sizeof(tt_user*))) == NULL) {
		my_debug(0, "mallloc failed");
		exit(1);
	}

	if (!(katalog = opendir(config_dir))) {
		perror("opendir()");
		exit(1);
	}

	while((pozycja = readdir(katalog)) != NULL) {
		if (strcmp(pozycja->d_name, ".") == 0 || strcmp(pozycja->d_name, "..") == 0)
			continue;

		if ((user = users_read(pozycja->d_name)) == NULL) {
			my_debug(0, "users_read failed");
			exit(1);
		}

		if ((tt_users = (tt_user**)realloc(tt_users, (i+2)*sizeof(tt_user*))) == NULL) {
			my_debug(0, "reallloc failed");
			exit(1);
		}

		tt_users[i] = user;
		i++;
	}
	closedir(katalog);
	tt_users[i] = NULL;

	my_debug(0, "Wczytano %d userow", users_size());

	return 0;
}
示例#8
0
int pgsql_connect(void)
{
    //char aux[64] = "";
    //conecta no banco utilizando connInfo
        
    conn = PQconnectdb( db_connect_string );
    
    //      conn = PQconnectdb("host=localhost port=5432");
    
    if (conn && PQstatus(conn) == CONNECTION_OK) {
        my_debug("PostgreSQL IPBX: Successfully connected to database.\n");
        return 1;
    }
    else {
        char *retString;
        retString = PQerrorMessage(conn);
        my_debug(retString);
        free(retString);
        return 0;
    }
}
示例#9
0
main(int argc, char *argv[]) {
    
    my_debug(argv[1]);
        
    read_config();
    
    if (!pgsql_connect())
        return 0;
    
    generate_registry(argv[1]);
    
    
    PQfinish(conn);

}
示例#10
0
int main (int argc, char **argv)
{
	/* el primer argumento es el nombre del programa así que pasamos de el */
	argv++;
	argc--;
	
	if (argc!= 1)
		usage();
	
	handler(argv);

	my_debug(repair);

	exit (0);
}
示例#11
0
void		my_compute(int *pile1, int *pile2, int size, int opt)
{
	int		c;
	int		ret;
	char	*buf;
	int		r[3][5];

	r[0][4] = opt;
	my_init1(&c, r[0], size, &buf);
	while (++c && (r[0][3] = my_sort(pile1, r[0][1], size, -1)))
	{
		if (my_init2(pile1, pile2, r[0], r) && r[0][4] == 2)
			my_debug(pile1, pile2, r[0][1], r[0][2]);
		if ((ret = check_a(pile1, pile2, &buf, r)) == 0)
			return ;
		else if (ret == 1)
			continue ;
		if ((ret = check_b(pile1, pile2, &buf, r)) == 0)
			return ;
	}
	if (opt == 2)
		my_debug(pile1, pile2, r[0][1], r[0][2]);
	return (my_end(opt, c - 1, buf, **r - 1));
}
示例#12
0
int main()
{
	rcc_clock_enable();
	delay_config();
	usart6_init(115200);
	
	STM_EVAL_LEDInit(LED3);
	STM_EVAL_LEDInit(LED4);
	STM_EVAL_LEDInit(LED5);
	STM_EVAL_LEDInit(LED6);
	
	//android远程控制初始化
	remote_control_init();
	//红外测距模块ADC初始化
	adc_tim_trig_config(500, 8400);
	//电机初始化
	motor_init();
	//光电开关初始化
	light_senser_init();
	//编码器初始化
	capture_config();
	//系统运行时间初始化
	micros_time_init();
#ifndef DEBUG_HAHA
//	//等待开始信号
//	usart_wait_signal();
//	//发送应答信号
//	usart_send_signal();
	while(remote_flag == 0);
	if(car_mode == MODE_SINGLE){
		usart_sendByte(USART6, '1');
	}
	else{
		usart_sendByte(USART6, '0');
	}
	//设置小车前进速度
	car_set_global_speed();
#endif
	STM_EVAL_LEDOn(LED3);
	while(1){
#ifdef DEBUG_HAHA
		my_debug();
#else
		control_process();
#endif
	}
}
示例#13
0
void read_config(void)
{
    FILE    *file;
    char var[200], val[200];
    
    char dbhost[40], dbname[20], dbuser[20], dbpass[20];
    int dbport;
    
    file = fopen("/usr/local/ipbx/ipbx.conf", "a+");
    
    /* Default values */
    strcpy(dbhost, "localhost");
    strcpy(dbname, "ipbx");
    strcpy(dbuser, "ipbx");
    strcpy(dbpass, "ipbx");
    dbport = 5432;
    
    /* Read values from conf file */   
    
    while (fscanf(file, "%s = %s", var, val) != EOF) {
        
        if (!strcmp(var, "hostname")) {
            strcpy(dbhost, val);        
        } else {
            if (!strcmp(var, "dbname")) {
                strcpy(dbname, val);        
            } else {
                if (!strcmp(var, "user")) {
                    strcpy(dbuser, val);        
                } else  {
                    if (!strcmp(var, "password")) {
                        strcpy(dbpass, val);        
                    } else {
                        if (!strcmp(var, "port")) {
                            //strcpy(dbport, val);        
                            dbport = atoi(val);
                        } else {
                        } } } } } 
        
    }
    
    fclose(file);
  
    sprintf(db_connect_string, "host=%s port=%i dbname=%s user=%s password=%s connect_timeout=8", dbhost, dbport, dbname, dbuser, dbpass);
   
    my_debug(db_connect_string);    
}
示例#14
0
/**
 * 正规矩形是否包含点
 */
gboolean 		my_util_is_point_in_rect	(	gdouble rectX, 
												gdouble rectY, 
												gdouble width, 
												gdouble height, 
												gdouble x, 
												gdouble y) {

	gboolean isInRect;
	if (rectX <= x && x <= (rectX + width)
		&& rectY <= y && y <= (rectY + height)) {
		isInRect = TRUE;
	} else {
		isInRect = FALSE;
	}
	my_debug ("Is point (%f,%f) in rect (%f,%f,%f,%f) ? %d", x, y, rectX, rectY, width, height, isInRect);
	return isInRect;
}
示例#15
0
文件: logout.c 项目: Doap/transports
int jabber_logout() {
	tt_user **user, *user0;
	/* Robimy sie niedostepni */
	for (user = tt_users; *user; user++) {
		user0 = *user;
		if (user0->tlen_loged) {
			/* jabber_sndpresence(config_myjid, user0->jid, NULL, "unavailable", NULL); */
			jabber_sndpresence(config_myjid, user0->jid, "unavailable", NULL, NULL);
		}
	}

	my_debug(2, "jabber: Zamkniecie stream!");
	jabber_send("</stream:stream>\n");
	jabber_loged = 0;
	t_free(js_buf);
	t_free(sid);
	return 0;
}
示例#16
0
GQueue * 		my_util_delete_queue_element	(GQueue *queue,
											 MyQueueDeleteFunc deleteFunc,
											 gpointer user_data) {
	
	guint i, len;
	GQueue *tmpQ;
	gpointer data;
	tmpQ = g_queue_new();
	// 双队列实现删除
	for (i = 0, len = g_queue_get_length (queue); i < len; i++){
		data = g_queue_peek_nth (queue, i);
		if (deleteFunc (data, user_data)) {
			my_debug ("deleting data %#x", data);
		} else {
			g_queue_push_tail (tmpQ, data);
		}
	}
	return tmpQ;
}
示例#17
0
文件: users.c 项目: Doap/transports
int users_unlink(const char *jid) {
	char *file;

	if (jid == NULL)
		return -1;

	if ((file = malloc(strlen(config_dir) + strlen(jid) + 2)) == NULL) {
		perror("malloc()");
		exit(1);
	}
	sprintf(file, "%s/%s", config_dir, jid);

	my_debug(0, "users: Usuwam plik %s!!", file);

	unlink(file);
	t_free(file);

	return 0;
}
示例#18
0
文件: users.c 项目: Doap/transports
tt_user *users_save(const char *jid) {
	tt_user **user, *user0;
	xode cfg, x;
	char *file;

	if (jid == NULL)
		return NULL;

	if ((file = malloc(strlen(config_dir) + strlen(jid) + 2)) == NULL) {
		perror("malloc()");
		exit(1);
	}
	sprintf(file, "%s/%s", config_dir, jid);

	my_debug(0, "users: Zapisuje plik %s", file);

	user = jid_jid2user(jid);
	user0 = *user;

	cfg = xode_new("user");

	x = xode_insert_tag(cfg, "jid");
	xode_insert_cdata(x, user0->jid, -1);

	x = xode_insert_tag(cfg, "tid");
	xode_insert_cdata(x, user0->tid_short, -1);

	x = xode_insert_tag(cfg, "password");
	xode_insert_cdata(x, user0->password, -1);

	x = xode_insert_tag(cfg, "notify");
	xode_put_attrib(x, "mail", (user0->mailnotify ? "1" : "0"));
	xode_put_attrib(x, "typing", (user0->typingnotify ? "1" : "0"));
	xode_put_attrib(x, "alarm", (user0->alarmnotify ? "1" : "0"));

	xode_to_file(file, cfg);
	xode_free(cfg);
	t_free(file);

	return user0;
}
示例#19
0
/**
 * 判断给定点(x,y)是否落在线段内
 * strokeWidth	半径
 */
gboolean		my_util_is_point_inside_segment		(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x, gdouble y, gdouble strokeWidth) {

  gdouble x3, y3, x4, y4, x5, y5, x6, y6, 
		rate, dx, dy, distance;
  gboolean isInRect;
  gdouble theLastX = x0;
  gdouble theLastY = y0;
  gdouble currentX = x1;
  gdouble currentY = y1;
	if (theLastX == currentX) { // 线段垂直情况
		x3 = theLastX - strokeWidth;
		y3 = theLastY;
		x4 = theLastX + strokeWidth;
		y4 = theLastY;
		x5 = x4;
		y5 = currentY;
		x6 = x3;
		y6 = currentY;
	} else {
		rate = (currentY - theLastY) / (currentX - theLastX);
		distance = sqrt((currentY - theLastY) * (currentY - theLastY) + (currentX - theLastX) * (currentX - theLastX));
		my_debug ("rate: %f, distance: %f", rate, distance);
		dx = abs( strokeWidth * (currentY - theLastY) / distance);
		dy = abs( strokeWidth * (currentX - theLastX) / distance);
		my_debug ("dx: %f, dy: %f", dx, dy);
		if (rate >= 0) {
			x3 = theLastX - dx;
			y3 = theLastY + dy;
			x4 = theLastX + dx;
			y4 = theLastY - dy;
			x5 = currentX + dx;
			y5 = currentY - dy;
			x6 = currentX - dx;
			y6 = currentY + dy;
		} else {
			x3 = theLastX - dx;
			y3 = theLastY - dy;
			x4 = theLastX + dx;
			y4 = theLastY + dy;
			x5 = currentX + dx;
			y5 = currentY + dy;
			x6 = currentX - dx;
			y6 = currentY - dy;
		}
	}
	my_debug ("x: %f, y: %f, x3: %f, y3: %f, x4: %f, y4: %f, x5: %f, y5: %f, x6: %f, y6: %f,", 
									x, y,
									x3, y3,
									x4, y4,
									x5, y5,
									x6, y6);
	isInRect = my_util_is_point_inside_rect (	
									x, y,
									x3, y3,
									x4, y4,
									x5, y5,
									x6, y6);
	if (isInRect) {
		my_debug ("line segment: (%f,%f) (%f,%f), mouse: (%f,%f). Select the target. OOOOOOOOO ", 
				theLastX, theLastY, currentX, currentY, x, y);
		
		return TRUE;
	}
	return FALSE;
}
示例#20
0
static void		draw_self_shadow	(MyShape* self, ApplicationState *appState) {

	
	MyBezier *bez = MY_BEZIER (self);
	cairo_t *cr = appState->cr;
	gdouble scale = appState->scale;
	
	MyVector newP0, newP1, newP2, newP3;
	MyBezierSinPrivate* priv = MY_BEZIER_SIN_GET_PRIVATE (self);
	
	gdouble currentX, currentY, theLastX, theLastY,
			segmentLen, // 当前两点间线段的长度
			totalLen, 	// 当前point到线起点的总距离
			sinStartLen, // 下一个正弦点应出现的位置. 线的起点到下一个正弦点的起点的距离
			sinDrawnCount, 	// 已画正弦点的个数
			beyondLastPointLen,
			offset,
			interval,
			amplitude,
			zhouqi,
			phase;
	MyPoint sinPoint;	// 正弦点
	
	MyVector q0, q1;
	gdouble t;
	int i;
	MyVector segmentUnitV,		// 线段的单位向量
			segmentV,
			perpUnitV,
			sinV;
	
	cairo_save (cr);
		
	cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
	
	
	newP0.x = bez->p0.x;
	newP0.y = bez->p0.y;
	newP1.x = bez->p1.x;
	newP1.y = bez->p1.y;
	newP2.x = bez->p2.x;
	newP2.y = bez->p2.y;
	newP3.x = bez->p3.x;
	newP3.y = bez->p3.y;
	
	
	
	totalLen = 0;
	sinDrawnCount = 0;
	offset = priv->offset * self->appState->scale;
	interval = priv->interval * self->appState->scale;
	amplitude = priv->amplitude * self->appState->scale;
	zhouqi = priv->zhouqi * self->appState->scale;
	phase = priv->phase * self->appState->scale;
	sinStartLen = offset;
	
	q0 = calculateBezierPoint (0, newP0, newP1, newP2, newP3);
	theLastX = q0.x;
	theLastY = q0.y;
	for (i = 1; i <= priv->segmentCount; i++) {
		t = i / priv->segmentCount;
		q1 = calculateBezierPoint(t, newP0, newP1, newP2, newP3);
		currentX = q1.x;
		currentY = q1.y;
		my_debug ("theLastXY %f,%f", theLastX, theLastY);
		my_debug ("currentXY %f,%f", currentX, currentY);
		//if (k != 0) { // 从第二个点开始有线段
			segmentV = my_vector_new (theLastX, theLastY, currentX, currentY);
			segmentUnitV = my_vector_norm (segmentV);
			perpUnitV = my_vector_perpendicular (segmentUnitV);
			
			my_debug ("segment vector %f,%f", segmentV.x, segmentV.y);
			my_debug ("segmentUnit vector %f,%f", segmentUnitV.x, segmentUnitV.y);
			my_debug ("perpUnit vector %f,%f", perpUnitV.x, perpUnitV.y);
			
			segmentLen = sqrt ((currentX - theLastX) * (currentX - theLastX) + (currentY - theLastY) * (currentY - theLastY) );
			totalLen += segmentLen;
			my_debug ("segmentLen %f", segmentLen);
			my_debug ("totalLen %f", totalLen);
			while (TRUE) {
				if (totalLen >= sinStartLen) { // 距离满足
					beyondLastPointLen = sinStartLen - (totalLen - segmentLen);
					sinPoint = my_util_part_segment (theLastX, theLastY, currentX, currentY, segmentLen, beyondLastPointLen);
					my_debug ("start beyondLastPointLen is %f", beyondLastPointLen);
					my_debug ("sinPoint is (%f,%f)", sinPoint.x, sinPoint.y);
					
					sinV = my_vector_scalar_mul (perpUnitV, 
												amplitude * sin(2*PI/zhouqi*sinStartLen + phase));
					my_debug ("sin vector %f,%f", sinV.x, sinV.y);
					
					cairo_line_to (cr, 
						(sinPoint.x + sinV.x) / scale - self->shadowX, 
						(sinPoint.y + sinV.y) / scale - self->shadowY);
					
					sinDrawnCount++;
					sinStartLen = offset + sinDrawnCount * interval;					
				} else {
					break;
				}
			}
		//}
		theLastX = currentX;
		theLastY = currentY;
	}	
	//cairo_set_dash (cr, NULL, 0, 0); // no dash with angle
	cairo_stroke (cr);
	
	cairo_restore (cr);
}
示例#21
0
guint	my_layer_shape_count (MyLayer *self) {
	
	MyLayerPrivate* priv = MY_LAYER_GET_PRIVATE (self);
	my_debug ("layer %#x has %u shapes", self, g_queue_get_length(priv->shapes));
	return g_queue_get_length(priv->shapes);
}
示例#22
0
文件: users.c 项目: Doap/transports
tt_user *users_read(const char *jid) {
	tt_user *user;
	xode cfg, x;
	char *file, *temp;

	if (jid == NULL)
		return NULL;

	if ((file = malloc(strlen(config_dir) + strlen(jid) + 2)) == NULL) {
		perror("malloc()");
		exit(1);
	}
	sprintf(file, "%s/%s", config_dir, jid);

	my_debug(0, "users: Wczytuje plik %s", file);

	if ((cfg = xode_from_file(file)) == NULL) {
		my_debug(0, "users: Nie moge wczytac usera");
		return NULL;
	}

	user = (tt_user*)malloc(sizeof(tt_user));
	memset(user, 0, sizeof(tt_user));

	x = xode_get_tag(cfg, "jid");
	temp = xode_get_data(x);
	my_strcpy(user->jid, temp);

	x = xode_get_tag(cfg, "tid");
	temp = xode_get_data(x);
	my_strcpy(user->tid_short, temp);

	user->tid = malloc(strlen(user->tid_short) + strlen("@tlen.pl") + 1);
	sprintf(user->tid, "*****@*****.**", user->tid_short);

	x = xode_get_tag(cfg, "password");
	temp = xode_get_data(x);
	my_strcpy(user->password, temp);

	user->tlen_sesja = NULL;
	user->tlen_loged = 0;
	user->last_ping_time = 0;

	user->roster = NULL;
	user->search = NULL;
	user->search_id = NULL;

	x = xode_get_tag(cfg, "notify");

	temp = xode_get_attrib(x, "mail");
	if (temp != NULL) {
		if (strcmp(temp, "1") == 0) {
			user->mailnotify = 1;
		} else if (strcmp(temp, "0") == 0) {
			user->mailnotify = 0;
		} else {
			user->mailnotify = 0;
			my_debug(0, "Blad w pliku");
		}
	} else {
		user->mailnotify = 0;
	}

	temp = xode_get_attrib(x, "typing");
	if (temp != NULL) {
		if (strcmp(temp, "1") == 0) {
			user->typingnotify = 1;
		} else if (strcmp(temp, "0") == 0) {
			user->typingnotify = 0;
		} else {
			user->typingnotify = 0;
			my_debug(0, "Blad w pliku");
		}
	} else {
		user->typingnotify = 0;
	}

	temp = xode_get_attrib(x, "alarm");
	if (temp != NULL) {
		if (strcmp(temp, "1") == 0) {
			user->alarmnotify = 1;
		} else if (strcmp(temp, "0") == 0) {
			user->alarmnotify = 0;
		} else {
			user->alarmnotify = 0;
			my_debug(0, "Blad w pliku");
		}
	} else {
		user->alarmnotify = 0;
	}

	user->status = NULL;
	user->status_type = 0;

	user->jabber_status = NULL;
	user->jabber_status_type = NULL;

	xode_free(cfg);
	t_free(file);

	return user;
}
main(int argc, char *argv[]) {

    struct tm tm;
    struct timeval t0, t1;
    char mdate[20];
    char mtime[20];
    time_t t;
    suseconds_t	ut0, ut1;
//    FILE *file;
//    char size_file_name[40] = "";

    /* Get current time */
    gettimeofday(&t0, NULL);
    t=t0.tv_sec;
    ut0=t0.tv_usec;
    localtime_r(&t, &tm);
    strftime(mdate, 128, DATE_FORMAT, &tm);
    strftime(mtime, 128, TIME_FORMAT, &tm);

    char buff[2048] = "";

    // assign variables

    if (argv[1])
        strcpy(src, argv[1]);
//    if (argv[2])
//        strcpy(dst, argv[2]);

    // info to log file
    //my_debug("");
    sprintf(buff, "Date: %s %s, src/file name/uniqueid: %s", mdate, mtime, src);
    my_debug(buff);


    // check for errors

    if (!strlen(src)) {
        my_debug("No source provided, aborting...");
        return 0;
    }


    sprintf(full_filename_wav, "/tmp/%s.wav", src);
    my_debug(full_filename_wav);

    sprintf(mp3_in_tmp, "/tmp/%s.mp3", src);
    my_debug(mp3_in_tmp);


    if (!file_exists(full_filename_wav)){
        sprintf(buff, "No source WAV file %s found, aborting...", full_filename_wav);
	my_debug(buff);
        return 0;
    }



    sprintf(final_dst, "%s%s.mp3", final_folder, src);
    my_debug(final_dst);

    // convert file

    sprintf(buff, "/usr/local/bin/lame --resample 44.1 -b 32 -a %s %s", full_filename_wav, mp3_in_tmp);
    my_debug(buff);
    system(buff);


    if (!file_exists(mp3_in_tmp)){
        my_debug("Error converting WAV to MP3");
        return 0;
    } else {
        // move to correct location
        sprintf(buff, "mv %s %s", mp3_in_tmp, final_folder);
        my_debug(buff);
        system(buff);
    }

    mp3_size = file_size(final_dst);
    sprintf(buff, "MP3 size: %li", mp3_size);
    my_debug(buff);


    // delete uploaded wav file
    sprintf(buff, "rm %s", full_filename_wav);
    my_debug(buff);
    system(buff);

/*
    sprintf(size_file_name, "/tmp/%s", src);
    file = fopen(size_file_name,"a+");
    fprintf(file,"%li", mp3_size);
    fclose(file);
*/


    // connect to db

    read_config();

    if (!mysql_connect()) {
        my_debug("Cannot connect to DB, aborting...");
	return 0;
    }

    // update size of recording
    sprintf(buff,"UPDATE recordings SET size = '%li' WHERE uniqueid = '%s';", mp3_size, src);
    my_debug(buff);
    mysql_query(&mysql,buff);


    // rec sending/deleting over email script
    my_debug("Executing recording email/deleting control script");
    sprintf(buff, "/usr/local/mor/mor_record_control %s 0", src);
    my_debug(buff);
    system(buff);


    gettimeofday(&t1, NULL);
    ut1=t1.tv_usec;

    mysql_close(&mysql);

    my_debug("Script completed.\n\n");


}