Skip to content

Commit d1abc5b

Browse files
committedMar 29, 2019
first version
0 parents  commit d1abc5b

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed
 

‎README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is applocation development ver1

‎main.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdlib.h>
2+
#include "screen.h"
3+
#include <time.h>
4+
#include <stdio.h>
5+
int main() {
6+
int dec[COL],i; // 80-pirces of sound decibels
7+
srand(time(NULL));
8+
for(i=0;i<COL;i++) dec[i] = rand()%70+30;
9+
clearScreen();
10+
setColors(RED, bg(YELLOW));
11+
barChart(dec);
12+
resetColors();
13+
getchar();
14+
}

‎makefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
OBJ = main.o screen.o
2+
APPNAME = sound.out
3+
$(APPNAME) : $(OBJ)
4+
gcc -o $(APPNAME) $(OBJ)
5+
%.o: %.c
6+
gcc -c -o $@ $<
7+
8+
clean :
9+
rm $(APPNAME) $(OBJ)
10+
11+
tar :
12+
tar cf sound.tar *.c *.h makefile

‎screen.c

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
// this file contains screen functions. They are used to display
3+
// sound levels on a Putty screen as a bar chart
4+
5+
#include <stdio.h>
6+
#include "screen.h"
7+
void barChart(int db[]){
8+
int i,j;
9+
for(i=0; i<COL; i++){ //for 80 col
10+
for(j=0;j<db[i]/3;j++){
11+
printf("\033[%d;%dH",35-j,i+1);
12+
#ifdef UNICODE //conditional compilation
13+
printf("%s",BAR);
14+
#else
15+
printf("%c", '*');
16+
#endif
17+
}
18+
}
19+
}
20+
void clearScreen(void){
21+
printf("\033[2J");
22+
fflush(stdout); // for remote terminal (such as Putty)
23+
}
24+
25+
void setColors(short bg, short fg) {
26+
printf("\033[%d;%d;1m", bg,fg);
27+
fflush(stdout);
28+
}
29+
30+
void resetColors(void){
31+
printf("\033[0m");
32+
fflush(stdout);
33+
}

‎screen.h

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#define UNICODE
2+
enum COLORS{BLACK=30,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE};
3+
#define COL 80
4+
#define bg(c) (c+10)
5+
#define BAR "\u2590"
6+
// fucntion declarations
7+
void clearScreen(void);
8+
void setColors(short, short);
9+
void resetColors(void);
10+
void barChart(int []);

‎testcurl.c

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
#include <curl/curl.h>
3+
4+
int main(int argc, char **argv){
5+
CURL *c;
6+
CURLcode res;
7+
char poststr[128];
8+
9+
if(argc < 3){
10+
printf("Usage: %s [ID] [email]\n", argv[0]);
11+
return 1;
12+
}
13+
sprintf(poststr, "ID=%s&email=%s", argv[1], argv[2]);
14+
15+
curl_global_init(CURL_GLOBAL_ALL);
16+
c = curl_easy_init();
17+
if(c){
18+
curl_easy_setopt(c, CURLOPT_URL, "http://www.cc.puv.fi/~e1800951/curl.php");
19+
curl_easy_setopt(c, CURLOPT_POSTFIELDS, poststr);
20+
res = curl_easy_perform(c);
21+
if(res != CURLE_OK)
22+
printf("Communication is not OK\n");
23+
else
24+
printf("Data is sent\n");
25+
curl_easy_cleanup(c);
26+
}
27+
curl_global_cleanup();
28+
return 0;
29+
}

0 commit comments

Comments
 (0)