Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
2666f3be
Kaydet (Commit)
2666f3be
authored
Eyl 22, 2005
tarafından
Gürer Özen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
dönen değerleri de okumak lazım
üst
f2ec91f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
14 deletions
+92
-14
hav.c
comard/bindings/hav.c
+31
-1
libcomar.c
comard/bindings/libcomar.c
+59
-13
libcomar.h
comard/bindings/libcomar.h
+2
-0
No files found.
comard/bindings/hav.c
Dosyayı görüntüle @
2666f3be
...
...
@@ -56,6 +56,9 @@ static void
do_register
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
com
=
comar_connect
();
if
(
!
com
)
{
...
...
@@ -76,7 +79,9 @@ do_register(char *argv[])
);
if
(
opt_wait
)
{
sleep
(
5
);
while
(
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
,
-
1
))
{
printf
(
"cmd=%d, id=%d, arg=[%s]
\n
"
,
cmd
,
id
,
ret
);
}
}
comar_disconnect
(
com
);
...
...
@@ -85,6 +90,31 @@ do_register(char *argv[])
static
void
do_remove
(
char
*
argv
[])
{
comar_t
*
com
;
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
if
(
!
argv
[
optind
])
{
print_usage
();
exit
(
1
);
}
comar_send
(
com
,
1
,
COMAR_REMOVE
,
argv
[
optind
],
NULL
);
if
(
opt_wait
)
{
sleep
(
5
);
}
comar_disconnect
(
com
);
}
static
void
...
...
comard/bindings/libcomar.c
Dosyayı görüntüle @
2666f3be
...
...
@@ -19,6 +19,27 @@
#include "libcomar.h"
// unpack utilities
// rpc uses network byte order (big endian)
static
inline
unsigned
int
get_cmd
(
const
unsigned
char
*
buf
)
{
return
buf
[
0
];
}
static
inline
unsigned
int
get_data_size
(
const
unsigned
char
*
buf
)
{
return
buf
[
3
]
+
(
buf
[
2
]
<<
8
)
+
(
buf
[
1
]
<<
16
);
}
static
inline
unsigned
int
get_id
(
const
unsigned
char
*
buf
)
{
return
buf
[
3
]
+
(
buf
[
2
]
<<
8
)
+
(
buf
[
1
]
<<
16
)
+
(
buf
[
0
]
<<
24
);
}
struct
comar_struct
{
int
sock
;
};
...
...
@@ -50,6 +71,12 @@ comar_connect(void)
return
com
;
}
int
comar_get_fd
(
comar_t
*
com
)
{
return
com
->
sock
;
}
int
comar_send
(
comar_t
*
com
,
unsigned
int
id
,
int
cmd
,
...)
{
...
...
@@ -95,22 +122,41 @@ comar_send(comar_t *com, unsigned int id, int cmd, ...)
return
0
;
}
int
comar_read
(
comar_t
*
com
,
int
*
cmdp
,
unsigned
int
*
idp
,
char
**
strp
,
int
timeout
)
{
fd_set
fds
;
struct
timeval
tv
;
struct
timeval
*
tvp
;
size_t
size
;
char
head
[
8
];
char
*
buf
;
FD_ZERO
(
&
fds
);
FD_SET
(
com
->
sock
,
&
fds
);
tv
.
tv_sec
=
timeout
;
tv
.
tv_usec
=
0
;
if
(
timeout
!=
-
1
)
tvp
=
&
tv
;
else
tvp
=
NULL
;
if
(
select
(
com
->
sock
+
1
,
&
fds
,
NULL
,
NULL
,
tvp
)
>
0
)
{
recv
(
com
->
sock
,
head
,
8
,
0
);
*
cmdp
=
get_cmd
(
head
);
*
idp
=
get_id
(
head
);
*
strp
=
NULL
;
size
=
get_data_size
(
head
+
4
);
if
(
size
)
{
buf
=
malloc
(
size
+
1
);
recv
(
com
->
sock
,
buf
,
size
,
0
);
buf
[
size
]
=
'\0'
;
*
strp
=
buf
;
}
}
return
1
;
}
void
comar_disconnect
(
comar_t
*
com
)
{
close
(
com
->
sock
);
free
(
com
);
}
#ifdef COMAR_TEST
int
main
(
int
argc
,
char
*
argv
[])
{
comar_t
*
com
;
com
=
comar_connect
();
comar_send
(
com
,
0
,
COMAR_CALL
,
"Time.Clock.getDate"
,
NULL
);
return
0
;
}
#endif
comard/bindings/libcomar.h
Dosyayı görüntüle @
2666f3be
...
...
@@ -38,7 +38,9 @@ struct comar_struct;
typedef
struct
comar_struct
comar_t
;
comar_t
*
comar_connect
(
void
);
int
comar_get_fd
(
comar_t
*
com
);
int
comar_send
(
comar_t
*
com
,
unsigned
int
id
,
int
cmd
,
...);
int
comar_read
(
comar_t
*
com
,
int
*
cmdp
,
unsigned
int
*
idp
,
char
**
strp
,
int
timeout
);
void
comar_disconnect
(
comar_t
*
com
);
...
...
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