Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
b1d88355
Commit
b1d88355
authored
Oct 22, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added send_text query
parent
e2cc2ed7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
interface.c
interface.c
+17
-0
queries.c
queries.c
+20
-0
queries.h
queries.h
+1
-0
No files found.
interface.c
View file @
b1d88355
...
...
@@ -35,6 +35,7 @@ char *commands[] = {
"dialog_list"
,
"send_photo"
,
"send_video"
,
"send_text"
,
0
};
int
commands_flags
[]
=
{
...
...
@@ -46,6 +47,7 @@ int commands_flags[] = {
07
,
0732
,
0732
,
0732
,
};
char
*
a
=
0
;
...
...
@@ -255,6 +257,21 @@ void interpreter (char *line UU) {
Peers
[
index
]
->
id
,
strndup
(
f
,
len
));
}
}
}
else
if
(
!
memcmp
(
line
,
"send_text"
,
9
))
{
char
*
q
=
line
+
10
;
int
len
;
char
*
text
=
get_token
(
&
q
,
&
len
);
int
index
=
0
;
while
(
index
<
user_num
+
chat_num
&&
(
!
Peers
[
index
]
->
print_name
||
strncmp
(
Peers
[
index
]
->
print_name
,
text
,
len
)))
{
index
++
;
}
if
(
index
<
user_num
+
chat_num
)
{
int
len
=
0
;
char
*
f
=
get_token
(
&
q
,
&
len
);
if
(
len
>
0
)
{
do_send_text
(
Peers
[
index
],
strndup
(
f
,
len
));
}
}
}
else
if
(
!
memcmp
(
line
,
"history"
,
7
))
{
char
*
q
=
line
+
7
;
int
len
;
...
...
queries.c
View file @
b1d88355
...
...
@@ -486,6 +486,26 @@ void do_send_message (union user_chat *U, const char *msg) {
print_message
(
M
);
}
void
do_send_text
(
union
user_chat
*
U
,
char
*
file_name
)
{
int
fd
=
open
(
file_name
,
O_RDONLY
);
if
(
fd
<
0
)
{
rprintf
(
"No such file '%s'
\n
"
,
file_name
);
free
(
file_name
);
return
;
}
static
char
buf
[(
1
<<
20
)
+
1
];
int
x
=
read
(
fd
,
buf
,
(
1
<<
20
)
+
1
);
if
(
x
==
(
1
<<
20
)
+
1
)
{
rprintf
(
"Too big file '%s'
\n
"
,
file_name
);
free
(
file_name
);
close
(
fd
);
}
else
{
do_send_message
(
U
,
buf
);
free
(
file_name
);
close
(
fd
);
}
}
int
get_history_on_answer
(
struct
query
*
q
UU
)
{
static
struct
message
*
ML
[
10000
];
int
i
;
...
...
queries.h
View file @
b1d88355
...
...
@@ -48,6 +48,7 @@ double get_double_time (void);
void
do_update_contact_list
(
void
);
union
user_chat
;
void
do_send_message
(
union
user_chat
*
U
,
const
char
*
msg
);
void
do_send_text
(
union
user_chat
*
U
,
char
*
file
);
void
do_get_history
(
union
user_chat
*
U
,
int
limit
);
void
do_get_dialog_list
(
void
);
void
do_send_photo
(
int
type
,
int
to_id
,
char
*
file_name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment