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
2515b1ef
Kaydet (Commit)
2515b1ef
authored
Şub 06, 2008
tarafından
Bahadır Kandemir
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
moved to branch
üst
b7ab39c1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
0 additions
and
2820 deletions
+0
-2820
Doxyfile
comar/Doxyfile
+0
-0
README
comar/README
+0
-161
SConstruct
comar/SConstruct
+0
-131
SConscript
comar/bindings/SConscript
+0
-9
comar.h
comar/bindings/comar.h
+0
-86
hav.c
comar/bindings/hav.c
+0
-388
libcomar.c
comar/bindings/libcomar.c
+0
-254
SConscript
comar/csapi/SConscript
+0
-25
csapi.c
comar/csapi/csapi.c
+0
-109
model.xml
comar/etc/model.xml
+0
-0
security-comments.xml
comar/etc/security-comments.xml
+0
-0
security-policy.xml
comar/etc/security-policy.xml
+0
-23
acl.h
comar/include/acl.h
+0
-24
cfg.h
comar/include/cfg.h
+0
-25
csl.h
comar/include/csl.h
+0
-29
data.h
comar/include/data.h
+0
-32
event.h
comar/include/event.h
+0
-22
i18n.h
comar/include/i18n.h
+0
-36
iksemel.h
comar/include/iksemel.h
+0
-0
job.h
comar/include/job.h
+0
-20
log.h
comar/include/log.h
+0
-26
model.h
comar/include/model.h
+0
-44
notify.h
comar/include/notify.h
+0
-19
process.h
comar/include/process.h
+0
-91
utility.h
comar/include/utility.h
+0
-40
ca.po
comar/po/ca.po
+0
-64
comar.pot
comar/po/comar.pot
+0
-45
de.po
comar/po/de.po
+0
-66
es.po
comar/po/es.po
+0
-66
fr.po
comar/po/fr.po
+0
-66
it.po
comar/po/it.po
+0
-67
nl.po
comar/po/nl.po
+0
-66
pl.po
comar/po/pl.po
+0
-65
pt_BR.po
comar/po/pt_BR.po
+0
-66
tr.po
comar/po/tr.po
+0
-62
SConscript
comar/src/SConscript
+0
-24
acl.c
comar/src/acl.c
+0
-305
cfg.c
comar/src/cfg.c
+0
-131
csl.c
comar/src/csl.c
+0
-0
data.c
comar/src/data.c
+0
-0
event.c
comar/src/event.c
+0
-131
iksemel.c
comar/src/iksemel.c
+0
-0
job.c
comar/src/job.c
+0
-0
log.c
comar/src/log.c
+0
-0
main.c
comar/src/main.c
+0
-0
model.c
comar/src/model.c
+0
-0
notify.c
comar/src/notify.c
+0
-0
process.c
comar/src/process.c
+0
-0
rpc_unix.c
comar/src/rpc_unix.c
+0
-0
utility.c
comar/src/utility.c
+0
-0
valgrind.sh
comar/valgrind.sh
+0
-2
No files found.
comar/Doxyfile
deleted
100644 → 0
Dosyayı görüntüle @
b7ab39c1
This diff is collapsed.
Click to expand it.
comar/README
deleted
100644 → 0
Dosyayı görüntüle @
b7ab39c1
COMAR 1.16
==========
Nedir:
------
COMAR (COnfiguration MAnageR), sistemin düzgün çalışması için gerekli olan
donanım, açılış, ağ, kullanıcı, zaman, görüntü gibi ayarların mümkün olduğu
kadar otomatik bir biçimde yapılmasını sağlayan, kullanıcılara bir yetki
kontrolü dahilinde bu ayarları basit ve anlaşılır bir biçimde değiştirme
olanağı sağlayan bir yazılımdır.
Lisans:
-------
Copyright (c) 2005-2007, TUBITAK/UEKAE
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. Please read the COPYING file.
Yayın hakkı (c) 2005-2007, TUBITAK/UEKAE
Bu program bir özgür yazılımdır; Free Software Foundation tarafından
yayımlanan GNU Genel Kamu Lisansının ikinci veya daha yüksek bir
sürümüne bağlı kalarak değiştirebilir ve/veya tekrar dağıtabilirsiniz.
Lisans metni için ekteki COPYING dosyasına bakın.
Çalıştırma:
-----------
Gerekenler:
Linux kernel 2.6.x
Python 2.4
Berkeley DB
scons
Standart inşa araçları (gcc, binutils, vs)
Sürüm 1.1 ile birlikte, Python binding ve betiklere ait API
comar-api paketine taşınmıştır. Düzgün çalışma için bu paketi
de kurmanız gereklidir.
Derleme:
İnşa sistemi olarak scons kullanılmıştır. Çomar yürütücüsü ve araçlarını inşa
etmek için:
scons
komutunu çalıştırmanız yeterlidir. İnşa işlemi "build" dizininde yapılacak ve
oluşturulan dosyalar "install" adlı bir dizine konacaktır. Sisteme kurulum
yapmak için
(sudo) scons install prefix=/
komutunu kullanmalısınız.
Çalıştırma:
comar bir sistem servisidir ve normal olarak init betiklerinden root yetkileriyle
çalıştırılır. Sistemde ikinci bir comar çalıştırıldığında ilkini kapatacaktır.
Çalışan comar'ı kapatmak için "Comar" adlı sürece SIGTERM sinyali gönderebilir
yada
(sudo) comar --stop
komutunu verebilirsiniz. Tabi bunun için root yetkilerine sahip olmanız gerekir.
Diğer komut satırı parametrelerini,
comar --help
komutuyla görebilirsiniz. Normal bir çalışma sırasında
ps ax
ile görebileceğiniz sistem süreçleri listesinde
Comar
ComarRPC
ComarEvent
olmak üzere üç süreç bulunacaktır. Bir yapılandırma görevi yerine getirilirken
ComarJob
ComarSubJob
adlarında başka süreçler de görülebilir.
Hatalar:
Bir hatayla karşılaşırsanız yada daha fazla bilgi almak isterseniz
http://bugs.pardus.org.tr
http://www.pardus.org.tr/projeler/comar
adreslerini kullanabilirsiniz.
Teknik Detaylar:
----------------
Süreçler:
* Comar Ana süreç
* ComarRPC Programlarla bağlantı kanalı
* ComarEvent Olay dinleyici
* ComarJob Her bir yapılandırma görevi için çalışan betikler
* ComarSubJob " " "
Modüller:
* main.c Ana süreç
* model.c Sistem modelini yükleme/indeksleme
* data.c Veritabanı (acl, script, apps, model, config)
* acl.c Yetki denetimi
* csl.c CSL - Python VM yardımcıları
* job.c İş yapan süreçler (Register, Execute, Remove script)
* process.c Süreç yönetimi ve süreçler arası iletişim
* cfg.c Komut satırı parametreleri
* log.c Hata ve bilgi kayıtları
* event.c Olay bildirim sistemi
* rpc_unix.c Unix soket üzerinden comar çağrısı modülü
* iksemel.c Dahili minimal XML parser
Kod stili:
* K&R
* Fonksiyon isimleri (module)_(görev) şeklinde
* Ana süreçte hazırlık işlemleri (module)_init
* Yeni bir süreç başlatan fonksiyonlar (module)_start [ _(opsiyonel isim)]
RPC:
"/var/run/comar.socket" adlı UNIX soketinden bağlanılır.
Gelen ve giden cevaplar:
cmd datasize id data
--- ------------ --- -----------...
(1) (3) (4) (datasize) bytes
biçimdedir. Burada cmd, giden komut veya dönen cevap tipi,
data ise komutun datasize boyutundaki parametreleridir.
32bitlik id değeri client tarafından belirlenir, ve bu değer
ile yapılan çağrıdan gelen tüm cevaplarda aynen geri döner.
Komutlar:
...yazılacak...
comar/SConstruct
deleted
100644 → 0
Dosyayı görüntüle @
b7ab39c1
#!/usr/bin/python
import
os
import
sys
import
glob
import
shutil
from
distutils.sysconfig
import
get_config_var
as
pyconf
import
SCons.Warnings
SCons
.
Warnings
.
warningAsException
(
1
)
# Parameters
version
=
ARGUMENTS
.
get
(
'version'
,
'1.18'
)
prefix
=
ARGUMENTS
.
get
(
'prefix'
,
'install'
)
pyprefix
=
ARGUMENTS
.
get
(
'pythondir'
,
'auto'
)
# Source Distribution
distfiles
=
"""
SConstruct
README
etc/*.xml
src/*.c
src/SConscript
include/*.h
bindings/SConscript
bindings/*.c
bindings/*.h
csapi/SConscript
csapi/*.c
po/comar.pot
po/*.po
"""
if
'dist'
in
sys
.
argv
:
distdir
=
"comar-
%
s"
%
version
list
=
[]
for
t
in
Split
(
distfiles
):
list
.
extend
(
glob
.
glob
(
t
))
if
os
.
path
.
exists
(
distdir
):
shutil
.
rmtree
(
distdir
)
os
.
mkdir
(
distdir
)
for
file_
in
list
:
cum
=
distdir
[:]
for
d
in
os
.
path
.
dirname
(
file_
)
.
split
(
'/'
):
dn
=
os
.
path
.
join
(
cum
,
d
)
cum
=
dn
[:]
if
not
os
.
path
.
exists
(
dn
):
os
.
mkdir
(
dn
)
shutil
.
copy
(
file_
,
os
.
path
.
join
(
distdir
,
file_
))
os
.
popen
(
"tar -czf
%
s
%
s"
%
(
"comar-"
+
version
+
".tar.gz"
,
distdir
))
shutil
.
rmtree
(
distdir
)
Exit
(
0
)
# i18n
i18n_source_list
=
[
"src/main.c"
,
"src/cfg.c"
]
if
"update_messages"
in
sys
.
argv
:
os
.
system
(
"xgettext --default-domain=comar --keyword=_ --keyword=N_ -o po/comar.pot
%
s"
%
" "
.
join
(
i18n_source_list
))
for
item
in
os
.
listdir
(
"po"
):
if
item
.
endswith
(
".po"
):
os
.
system
(
"msgmerge -q -o temp.po po/
%
s po/comar.pot"
%
item
)
os
.
system
(
"cp temp.po po/
%
s"
%
item
)
os
.
system
(
"rm -f temp.po"
)
Exit
(
0
)
# Configuration
if
os
.
path
.
exists
(
"/etc/pardus-release"
):
# Jolly good, we are on a Pardus system
# Pisi and Comar python modules goes to the /usr/lib/pardus for reliability
# Python is patched to import from this directory first
pyprefix
=
'usr/lib/pardus'
if
sys
.
version_info
[
1
]
==
4
:
libs
=
[
'db'
,
'm'
,
"python2.4"
]
if
pyprefix
==
'auto'
:
pyprefix
=
'usr/lib/python2.5/site-packages'
else
:
libs
=
[
'db'
,
'm'
,
"python2.5"
]
if
pyprefix
==
'auto'
:
pyprefix
=
'usr/lib/python2.5/site-packages'
libpath
=
[
'/usr/lib'
]
cpppath
=
[
pyconf
(
'CONFINCLUDEPY'
),
"../include"
]
ccflags
=
"-O2 -Wall -DVERSION='
\"
%
s
\"
' "
%
version
env
=
Environment
(
CCFLAGS
=
ccflags
,
CPPPATH
=
cpppath
,
LIBS
=
libs
,
LIBPATH
=
libpath
)
# Build
env
.
SConsignFile
(
"sconsign"
)
Export
(
'env'
)
comar
=
SConscript
(
'src/SConscript'
,
build_dir
=
'build'
,
duplicate
=
0
)
libcomar
,
hav
=
SConscript
(
'bindings/SConscript'
,
build_dir
=
'build/bindings'
,
duplicate
=
0
)
csapi
=
SConscript
(
'csapi/SConscript'
,
build_dir
=
'build/csapi'
,
duplicate
=
0
)
# Install
bindir
=
os
.
path
.
join
(
prefix
,
'usr/bin'
)
libdir
=
os
.
path
.
join
(
prefix
,
'usr/lib'
)
incdir
=
os
.
path
.
join
(
prefix
,
'usr/include'
)
etcdir
=
os
.
path
.
join
(
prefix
,
'etc/comar'
)
pydir
=
os
.
path
.
join
(
prefix
,
pyprefix
)
if
"install"
in
sys
.
argv
:
for
item
in
os
.
listdir
(
"po"
):
if
item
.
endswith
(
".po"
):
lang
=
item
[:
-
3
]
dest
=
"usr/share/locale/
%
s/LC_MESSAGES/comar.mo"
%
lang
try
:
os
.
makedirs
(
os
.
path
.
dirname
(
os
.
path
.
join
(
prefix
,
dest
)))
except
:
pass
os
.
system
(
"msgfmt po/
%
s -o
%
s"
%
(
item
,
os
.
path
.
join
(
prefix
,
dest
)))
targets
=
[]
targets
.
append
(
env
.
Install
(
bindir
,
comar
))
targets
.
append
(
env
.
Install
(
etcdir
,
'etc/model.xml'
))
targets
.
append
(
env
.
Install
(
etcdir
,
'etc/security-policy.xml'
))
targets
.
append
(
env
.
Install
(
etcdir
,
'etc/security-comments.xml'
))
targets
.
append
(
env
.
Install
(
incdir
,
'bindings/comar.h'
))
targets
.
append
(
env
.
Install
(
libdir
,
libcomar
))
targets
.
append
(
env
.
Install
(
pydir
,
csapi
))
targets
.
append
(
env
.
Install
(
bindir
,
hav
))
env
.
Alias
(
'install'
,
targets
)
comar/bindings/SConscript
deleted
100644 → 0
Dosyayı görüntüle @
b7ab39c1
#!/usr/bin/python
Import
(
'env'
)
env2
=
env
.
Copy
(
LIBS
=
''
)
libcomar
=
env2
.
SharedLibrary
(
"libcomar"
,
[
"libcomar.c"
])
hav
=
env2
.
Program
(
"hav"
,
[
"libcomar.c"
,
"hav.c"
])
Return
(
'libcomar hav'
)
comar/bindings/comar.h
deleted
100644 → 0
Dosyayı görüntüle @
b7ab39c1
/*
** Copyright (c) 2005, TUBITAK/UEKAE
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 2 of the License, or (at your
** option) any later version. Please read the COPYING file.
*/
#ifndef COMAR_H
#define COMAR_H 1
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stddef.h>
#define COMAR_PIPE_NAME "/var/run/comar.socket"
// comar rpc commands, keep in sync with rpc_unix.c
// commands from the daemon
#define COMAR_RESULT 0
#define COMAR_FAIL 1
#define COMAR_NONE 2
#define COMAR_DENIED 3
#define COMAR_ERROR 4
#define COMAR_RESULT_START 5
#define COMAR_RESULT_END 6
#define COMAR_NOTIFY 7
// commands to the daemon
#define COMAR_LOCALIZE 8
#define COMAR_REGISTER 9
#define COMAR_REMOVE 10
#define COMAR_CALL 11
#define COMAR_CALL_PACKAGE 12
#define COMAR_ASKNOTIFY 13
#define COMAR_GETLIST 14
#define COMAR_CHECKACL 15
#define COMAR_DUMP_PROFILE 16
#define COMAR_CANCEL 17
#define COMAR_EVENT 18
#define COMAR_CMD_MAX 19
#define COMAR_CMD_NAMES \
"Result", \
"Fail", \
"None", \
"Denied", \
"Error", \
"ResultStart", \
"ResultEnd", \
"Notify", \
"Localize", \
"Register", \
"Remove", \
"Call", \
"CallPackage", \
"AskNotify", \
"GetList", \
"CheckACL", \
"DumpProfile", \
"Cancel", \
"Event",
struct
comar_struct
;
typedef
struct
comar_struct
comar_t
;
comar_t
*
comar_connect
(
void
);
int
comar_get_fd
(
comar_t
*
com
);
const
char
*
comar_cmd_name
(
int
cmd
);
void
comar_send_start
(
comar_t
*
com
,
unsigned
int
id
,
int
cmd
);
int
comar_send_arg
(
comar_t
*
com
,
const
char
*
str
,
size_t
size
);
int
comar_send_finish
(
comar_t
*
com
);
int
comar_send
(
comar_t
*
com
,
unsigned
int
id
,
int
cmd
,
...);
int
comar_wait
(
comar_t
*
com
,
int
timeout
);
int
comar_read
(
comar_t
*
com
,
int
*
cmdp
,
unsigned
int
*
idp
,
char
**
strp
);
char
*
comar_package_name
(
comar_t
*
com
);
void
comar_disconnect
(
comar_t
*
com
);
#ifdef __cplusplus
}
#endif
#endif
/* COMAR_H */
comar/bindings/hav.c
deleted
100644 → 0
Dosyayı görüntüle @
b7ab39c1
/*
** Copyright (c) 2005, TUBITAK/UEKAE
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 2 of the License, or (at your
** option) any later version. Please read the COPYING file.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <getopt.h>
#include <sys/stat.h>
#include "comar.h"
/* wait for comar reply */
int
opt_wait
=
1
;
static
struct
option
longopts
[]
=
{
{
"help"
,
0
,
0
,
'h'
},
{
"version"
,
0
,
0
,
'v'
},
{
"nowait"
,
0
,
0
,
'w'
},
{
0
,
0
,
0
,
0
}
};
static
char
*
shortopts
=
"hvw"
;
static
void
print_usage
(
void
)
{
puts
(
"Command line COMAR interface.
\n
"
"usage: hav [options] <command> [args]
\n
"
"commands:
\n
"
" call <method-name> [parameter value]...
\n
"
" call-package <method-name> <package-name> [parameter value]...
\n
"
" register <class> <package-name> <script-file>
\n
"
" remove <package-name>
\n
"
" list <class>
\n
"
" listen <notify-name>...
\n
"
" event <class-name> <func-name> <package-name> <data>
\n
"
" dump
\n
"
"options:
\n
"
" -w, --nowait Do not wait for an answer.
\n
"
"report bugs to <gurer@uludag.org.tr>"
);
}
static
void
do_call
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send_start
(
com
,
1
,
COMAR_CALL
);
for
(;
argv
[
optind
];
optind
++
)
{
comar_send_arg
(
com
,
argv
[
optind
],
0
);
}
comar_send_finish
(
com
);
if
(
opt_wait
)
{
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
if
(
cmd
==
COMAR_RESULT_START
)
{
while
(
cmd
!=
COMAR_RESULT_END
)
{
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
if
(
cmd
==
COMAR_RESULT
)
printf
(
"%s id=%d, pak=[%s], arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
comar_package_name
(
com
),
ret
);
else
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
}
}
}
comar_disconnect
(
com
);
}
static
void
do_call_package
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send_start
(
com
,
1
,
COMAR_CALL_PACKAGE
);
for
(;
argv
[
optind
];
optind
++
)
{
comar_send_arg
(
com
,
argv
[
optind
],
0
);
}
comar_send_finish
(
com
);
if
(
opt_wait
)
{
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
}
comar_disconnect
(
com
);
}
static
void
do_register
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
char
*
path
;
if
(
!
argv
[
optind
]
||
!
argv
[
optind
+
1
]
||
!
argv
[
optind
+
2
])
{
print_usage
();
exit
(
1
);
}
path
=
argv
[
optind
+
2
];
if
(
path
[
0
]
!=
'/'
)
{
path
=
realpath
(
path
,
NULL
);
}
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send
(
com
,
1
,
COMAR_REGISTER
,
argv
[
optind
],
argv
[
optind
+
1
],
path
,
NULL
);
if
(
opt_wait
)
{
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
}
comar_disconnect
(
com
);
}
static
void
do_remove
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
if
(
!
argv
[
optind
])
{
print_usage
();
exit
(
1
);
}
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send
(
com
,
1
,
COMAR_REMOVE
,
argv
[
optind
],
NULL
);
if
(
opt_wait
)
{
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
}
comar_disconnect
(
com
);
}
static
void
do_list
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
if
(
!
argv
[
optind
])
{
print_usage
();
exit
(
1
);
}
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send
(
com
,
1
,
COMAR_GETLIST
,
argv
[
optind
],
NULL
);
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
comar_disconnect
(
com
);
}
static
void
do_listen
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
while
(
argv
[
optind
])
{
comar_send
(
com
,
1
,
COMAR_ASKNOTIFY
,
argv
[
optind
],
NULL
);
++
optind
;
}
while
(
1
)
{
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
}
comar_disconnect
(
com
);
}
static
void
do_dump
(
char
*
argv
[])
{
comar_t
*
com
;
int
cmd
;
unsigned
int
id
;
char
*
ret
;
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send
(
com
,
1
,
COMAR_DUMP_PROFILE
,
NULL
);
comar_wait
(
com
,
-
1
);
if
(
!
comar_read
(
com
,
&
cmd
,
&
id
,
&
ret
))
{
puts
(
"Connection closed by COMAR daemon"
);
exit
(
2
);
}
printf
(
"%s id=%d, arg=[%s]
\n
"
,
comar_cmd_name
(
cmd
),
id
,
ret
);
comar_disconnect
(
com
);
}
static
void
do_event
(
char
*
argv
[])
{
comar_t
*
com
;
if
(
!
argv
[
optind
]
||
!
argv
[
optind
+
1
]
||
!
argv
[
optind
+
2
]
||
!
argv
[
optind
+
3
])
{
print_usage
();
exit
(
1
);
}
com
=
comar_connect
();
if
(
!
com
)
{
puts
(
"Cannot connect to COMAR daemon"
);
exit
(
2
);
}
comar_send
(
com
,
1
,
COMAR_EVENT
,
argv
[
optind
],
argv
[
optind
+
1
],
argv
[
optind
+
2
],
argv
[
optind
+
3
],
NULL
);
comar_disconnect
(
com
);
}
static
struct
cmd_s
{
const
char
*
cmd
;