[Uludag-commits] r15639 - trunk/comar/comar/src
uludag-commits at pardus.org.tr
uludag-commits at pardus.org.tr
4 Eki 2007 Per 15:06:25 EEST
Author: caglar
Date: Thu Oct 4 15:06:25 2007
New Revision: 15639
Modified:
trunk/comar/comar/src/acl.c
trunk/comar/comar/src/cfg.c
trunk/comar/comar/src/csl.c
trunk/comar/comar/src/data.c
trunk/comar/comar/src/job.c
trunk/comar/comar/src/log.c
trunk/comar/comar/src/main.c
trunk/comar/comar/src/model.c
trunk/comar/comar/src/notify.c
trunk/comar/comar/src/process.c
trunk/comar/comar/src/rpc_unix.c
trunk/comar/comar/src/utility.c
Log:
merged from staj-projeleri
Modified: trunk/comar/comar/src/acl.c
=================================================================
--- trunk/comar/comar/src/acl.c (original)
+++ trunk/comar/comar/src/acl.c Thu Oct 4 15:06:25 2007
@@ -37,12 +37,11 @@
static int
count_groups(iks *tag, int class_no)
{
- /*!
- Returns the number of group tags in child tags of 'tag'
- It also counts group tags under class tag ( class permissions )
- @return Returns number of groups
- */
-
+ /*!
+ Returns the number of group tags in child tags of 'tag'
+ It also counts group tags under class tag ( class permissions )
+ @return Returns number of groups
+ */
iks *x;
unsigned int nr = 0;
// global permissions
@@ -63,11 +62,10 @@
static void
add_allowed(gid_t gid)
{
- /*!
- This function allocates memory for allowed group id's. @see acl_allowed_gids
- Every group is added once
- */
-
+ /*!
+ This function allocates memory for allowed group id's. @see acl_allowed_gids
+ Every group is added once
+ */
static unsigned int max_allowed = 0;
unsigned int i;
@@ -94,12 +92,11 @@
static void
add_group(iks *tag, int level, struct acl_class *ac)
{
- /*!
- Scans the 'tag's 'name' attribute, and searches the result in groups database (unix groups db)
- When found, numerical group id and level is set to current group structure
- \param ac is the allocated memory for acl_group structure \param level is permissions level
- */
-
+ /*!
+ Scans the 'tag's 'name' attribute, and searches the result in groups database (unix groups db)
+ When found, numerical group id and level is set to current group structure
+ \param ac is the allocated memory for acl_group structure \param level is permissions level
+ */
struct acl_group *ag;
char *name;
struct group *grp;
@@ -122,12 +119,11 @@
static void
add_groups(iks *tag, int class_no, int level, struct acl_class *ac)
{
-· /*!
-· Searches 'tag' in 'group' and 'class' tags, calls add_group function with found tags
-· level and acl_class is passed to add_group
-· \sa add_group
-· */
-
+ /*!
+ Searches 'tag' in 'group' and 'class' tags, calls add_group function with found tags
+ level and acl_class is passed to add_group
+ \sa add_group
+ */
iks *x;
// global permissions
for (x = iks_find(tag, "group"); x; x = iks_next_tag(x)) {
@@ -146,12 +142,11 @@
static void
set_class(iks *model, int class_no)
{
-· /*!
-· Allocates memory for all found 'group's in 'model' @see count_groups()
-· Then add_groups is called and acl_class is put in node table
-· \sa add_groups
-· */
-
+ /*!
+ Allocates memory for all found 'group's in 'model' @see count_groups()
+ Then add_groups is called and acl_class is put in node table
+ \sa add_groups
+ */
struct acl_class *ac;
int nr_groups = 0;
@@ -174,11 +169,10 @@
void
acl_init(void)
{
-· /*!
-· Loads /etc/comar/security-policy.xml file
-· For all classes in model.xml file, look in security-policy if theres a match
-· */
-
+ /*!
+ Loads /etc/comar/security-policy.xml file
+ For all classes in model.xml file look in security-policy if theres a match
+ */
iks *policy;
iks *model;
int class_no;
@@ -211,11 +205,10 @@
static int
check_acl(int node, struct Creds *cred)
{
-· /*!
-· Checks if cred->uid user is capable to perform the action,
-· @return Returns 1 if capable, 0 otherwise
-· */
-
+ /*!
+ Checks if cred->uid user is capable to perform the action,
+ @return Returns 1 if capable, 0 otherwise
+ */
gid_t gids[64];
int nr_gids = 64;
struct passwd *pw;
@@ -249,16 +242,16 @@
return 0;
}
-//! Find if user is ok to execute command
+//! Find if user is ok to exec cmd
int
acl_is_capable(int cmd, int node, struct Creds *cred)
{
-· /*!
-· Checks if cred->uid user is capable executing command cmd.
-· Root is always capable, only CMD_CALL commands are allowed here
-· @return Returns 1 if allowed, 0 otherwise
-· */
-
+ /*!
+ Checks if cred->uid user is capable executing command cmd.
+ Root is always capable, only CMD_CALL commands are allowed here
+ @return Returns 1 if allowed, 0 otherwise
+ */
+ // root always capable
if (cred->uid == 0)
return 1;
@@ -274,11 +267,10 @@
int
acl_can_connect(struct Creds *cred)
{
-· /*!
-· Checks if user with user id cred->uid can connect comar.
-· @return Returns 1 if can connect, 0 otherwise
-· */
-
+ /*!
+ Checks if user with user id cred->uid can connect comar.
+ @return Returns 1 if can connect, 0 otherwise
+ */
gid_t gids[64];
int nr_gids = 64;
struct passwd *pw;
Modified: trunk/comar/comar/src/cfg.c
=================================================================
--- trunk/comar/comar/src/cfg.c (original)
+++ trunk/comar/comar/src/cfg.c Thu Oct 4 15:06:25 2007
@@ -17,7 +17,7 @@
#include "cfg.h"
#include "process.h"
-/* global option variables with defaults */
+// global option variables with defaults
char *cfg_model_file = "/etc/comar/model.xml";
char *cfg_data_dir = "/var/db/comar";
char *cfg_socket_name = "/var/run/comar.socket";
@@ -59,7 +59,7 @@
static void
print_usage(void)
{
- puts(
+puts(
_("Usage: comar [OPTIONS]\n"
"Pardus configuration manager.\n"
" -m, --model [FILE] Use the given xml model file.\n"
@@ -93,6 +93,9 @@
void
cfg_init(int argc, char *argv[])
{
+ /*!
+ Parses command line options
+ */
int c, i, j;
while ((c = getopt_long(argc, argv, shortopts, longopts, &i)) != -1) {
Modified: trunk/comar/comar/src/csl.c
=================================================================
--- trunk/comar/comar/src/csl.c (original)
+++ trunk/comar/comar/src/csl.c Thu Oct 4 15:06:25 2007
@@ -307,15 +307,20 @@
{ NULL, NULL, 0, NULL }
};
+//! Basic initialization
void
csl_setup(void)
{
Py_Initialize();
}
+//! Log exceptions
static void
log_exception(void)
{
+ /*! Log exceptions as errors.
+ \sa log.c log_error
+ */
PyObject *pType;
PyObject *pValue;
PyObject *pTrace;
@@ -323,6 +328,7 @@
char *vStr = "";
long lineno = 0;
+ // Retrieve the error indicator into variables
PyErr_Fetch(&pType, &pValue, &pTrace);
if (!pType) {
log_error("csl.c log_exception() called when there isn't an exception\n");
@@ -502,6 +508,7 @@
return 0;
}
+//! Finish
void
csl_cleanup(void)
{
Modified: trunk/comar/comar/src/data.c
=================================================================
Suppressed!
Too long (more than 250 lines) diff output suppressed...
Modified: trunk/comar/comar/src/job.c
=================================================================
--- trunk/comar/comar/src/job.c (original)
+++ trunk/comar/comar/src/job.c Thu Oct 4 15:06:25 2007
@@ -59,11 +59,8 @@
static int
do_register(int node, const char *app, const char *fname)
{
-· /*!
- Register script by first testing it by compiling.
-· If it compiles well, put script. \sa db_put_script csl_compile
- */
-
+ /*! Register script by first testing it by compiling
+ If it compiles well, put script. \sa db_put_script csl_compile*/
char *buf;
char *code;
size_t codelen;
@@ -150,13 +147,11 @@
static int
do_execute(int node, const char *app, struct pack *pak)
{
-· /*!
- Load the app code and execute it with python/c api @see csl.c
-· If execution lasts more than 6 seconds, logs this information @see log_info
-· Returns 0 on a successfull call, returns error returned by csl execute function otherwise
-· \sa csl.c
-· */
-
+ /*! Load the app code and execute it with python/c api @see csl.c
+ If execution lasts more than 6 seconds, logs this information @see log_info
+ Returns 0 on a successfull call, returns error returned by csl execute function otherwise
+ \sa csl.c
+ */
struct timeval start, end;
unsigned long msec;
struct pack *p = NULL;
@@ -234,11 +229,8 @@
static int
do_call(int node, struct pack *pak)
{
-· /*!
- Get scripts and run them, send results and return
-· @return Returns 0
- */
-
+ /*! Get scripts and run them, send results and return
+ @return Returns 0 */
struct pack *p = NULL;
char *apps;
int ok = 0;
@@ -362,10 +354,9 @@
static void
job_proc(void)
{
-· /*!
-· Listen for incoming requests and process the commands.
-· */
-
+ /*!
+ Listen for incoming requests and process the commands.
+ */
struct ipc_struct ipc;
struct pack *p;
struct ProcChild *sender;
@@ -374,7 +365,7 @@
size_t size;
p = pack_new(256);
- // wait untill theres something to listen
+ // wait untill theres something to listen
while (1) {
if (1 == proc_listen(&sender, &cmd, &size, 1)) break;
}
Modified: trunk/comar/comar/src/log.c
=================================================================
--- trunk/comar/comar/src/log.c (original)
+++ trunk/comar/comar/src/log.c Thu Oct 4 15:06:25 2007
@@ -47,12 +47,10 @@
static void
log_print(const char *fmt, va_list ap, int error)
{
-· /*!
- Writes log to file (cfg_log_file_name) or stdout according to cfg_log_* options
-· comar version, process id, timestamp and errors(if any) are written
-· \sa cfg.c
-· */
-
+ /*! Writes log to file (cfg_log_file_name) or stdout according to cfg_log_* options
+ comar version, process id, timestamp and errors(if any) are written
+ \sa cfg.c
+ */
if (cfg_log_console) {
pidstamp(stdout);
vprintf(fmt, ap);
@@ -89,11 +87,10 @@
void
log_error(const char *fmt, ...)
{
-· /*!
-· Same as log_info, if this function is called instead, writes
-· information as an 'error' to log file
-· */
-
+ /*!
+ Same as log_info, if this function is called instead, writes
+ information as an 'error' to log file
+ */
va_list ap;
va_start(ap, fmt);
@@ -105,12 +102,11 @@
void
log_info(const char *fmt, ...)
{
-· /*!
-· Prints log info of variable arguments with log_print function.
-· Console or file usage depends on cfg_log_* options
-· \sa log_print cfg.c
-· */
-
+ /*!
+ Prints log info of variable arguments with log_print function.
+ Console or file usage depends on cfg_log_* options
+ \sa log_print cfg.c
+ */
va_list ap;
va_start(ap, fmt);
Modified: trunk/comar/comar/src/main.c
=================================================================
--- trunk/comar/comar/src/main.c (original)
+++ trunk/comar/comar/src/main.c Thu Oct 4 15:06:25 2007
@@ -39,11 +39,11 @@
size_t size;
int sock;
- // create socket
+ // create socket
sock = socket(PF_LOCAL, SOCK_STREAM, 0);
if (sock == -1) return;
- // a local socket
+ // a local socket
name.sun_family = AF_LOCAL;
strncpy(name.sun_path, cfg_socket_name, sizeof (name.sun_path));
size = (offsetof (struct sockaddr_un, sun_path) + strlen (name.sun_path) + 1);
@@ -152,6 +152,5 @@
}
}
}
-
return 0;
}
Modified: trunk/comar/comar/src/model.c
=================================================================
--- trunk/comar/comar/src/model.c (original)
+++ trunk/comar/comar/src/model.c Thu Oct 4 15:06:25 2007
@@ -64,11 +64,10 @@
static int
prepare_tables(int max_nodes, size_t str_size)
{
-· /*!
-· @return Returns 0 if successfully allocates memory for nodes, node table and paths,
-· -1 otherwise
-· */
-
+ /*!
+ @return Returns 0 if successfully allocates memory for nodes, node table and paths,
+ -1 otherwise
+ */
nodes = calloc(max_nodes, sizeof(struct node));
node_table = calloc(TABLE_SIZE, sizeof(struct node *));
paths = malloc(str_size);
@@ -80,11 +79,10 @@
static int
add_node(int parent_no, const char *path, int type)
{
-· /*!
-· parent_no is depth of node. adds node with path and type (method)
-· to node table
-· */
-
+ /*!
+ parent_no is depth of node. adds node with path and type (method)
+ to node table
+ */
struct node *n;
int val;
int len = strlen(path);
@@ -115,12 +113,11 @@
static char *
build_path(iks *g, iks *o, iks *m)
{
-· /*!
-· Returns the 'name' attr of 'g' iks node (group)
-· if 'm' is given, returns it as group.object.method (names)
-· if 'o' is given, returns group.object (names)
-· */
-
+ /*!
+ Returns the 'name' attr of 'g' iks node (group)
+ if 'm' is given, returns it as group.object.method (names)
+ if 'o' is given, returns group.object (names)
+ */
if (path_ptr) {
path_ptr += strlen(path_ptr) + 1;
} else {
@@ -170,13 +167,12 @@
int
model_init(void)
{
-· /*!
-· This function parses model.xml file (cfg_model_file)
-· Converts model.xml's access levels and flags to ACL levels and
-· flags, and loads into memory before deleting dom tree
-· \sa cfg.c
-· */
-
+ /*!
+ This function parses model.xml file (cfg_model_file)
+ Converts model.xml's access levels and flags to ACL levels and
+ flags, and loads into memory before deleting dom tree
+ \sa cfg.c
+ */
iks *model;
iks *grp, *obj, *met;
int count = 0;
@@ -198,6 +194,7 @@
}
// FIXME: ugly code ahead, split into functions and simplify
+ // i agree
// scan the model
for (grp = iks_first_tag(model); grp; grp = iks_next_tag(grp)) {
@@ -244,7 +241,7 @@
}
}
- // size is counted to alloc mem for paths
+ // size is counted to alloc mem for paths
// prepare data structures
if (prepare_tables(count, size)) return -1;
@@ -335,11 +332,9 @@
int
model_lookup_method(const char *path)
{
-· /*!
- Lookup a method in node table.
-· @return If found, returns its number in table, returns -1 otherwise·
-· */
-
+ /*! Lookup a method in node table.
+ @return If found, returns its number in table, returns -1 otherwise
+ */
struct node *n;
int val;
@@ -356,11 +351,10 @@
int
model_lookup_notify(const char *path)
{
-· /*!
-· If specified path's record in node table has a type of 'notify'
-· returns its number in table, returns -1 otherwise
-· */
-
+ /*!
+ If specified path's record in node table has a type of 'notify'
+ returns its number in table, returns -1 otherwise
+ */
struct node *n;
int val;
@@ -377,11 +371,9 @@
int
model_parent(int node_no)
{
-· /*!
- if node_no numbered record in node table is a method, returns its parent number
-· else returns node_no
-· */
-
+ /*! if node_no numbered record in node table is a method, returns its parent number
+ else returns node_no
+ */
struct node *n;
n = &nodes[node_no];
@@ -414,10 +406,9 @@
int
model_has_argument(int node_no, const char *argname)
{
-· /*!
-· @return Returns 1 if argname is found in node table, 0 otherwise
-· */
-
+ /*!
+ @return Returns 1 if argname is found in node table, 0 otherwise
+ */
struct node *n;
int max, i;
const char *t;
@@ -491,12 +482,11 @@
void
model_acl_get(int node_no, void **acldatap, unsigned int *levelp)
{
-· /*!
-· This function gets 'acldata' and 'level' from node table, from record numbered 'node_no'
-· \param acldatap is pointer to acldata
-· \param levelp is pointer to level
-· */
-
+ /*!
+ This function gets 'acldata' and 'level' from node table, from record numbered 'node_no'
+ \param acldatap is pointer to acldata
+ \param levelp is pointer to level
+ */
struct node *n;
n = &nodes[node_no];
@@ -513,12 +503,11 @@
int
model_next_class(int *class_nop)
{
-· /*!
-· Scans node table for class tags
-· @return If found, returns 1 and sets the node number to given argument (class_nop) \n
-· Returns 0 if no classes found
-· */
-
+ /*!
+ Scans node table for class tags
+ @return If found, returns 1 and sets the node number to given argument (class_nop) \n
+ Returns 0 if no classes found
+ */
int no;
struct node *n;
@@ -534,3 +523,4 @@
*class_nop = -1;
return 0;
}
+
Modified: trunk/comar/comar/src/notify.c
=================================================================
--- trunk/comar/comar/src/notify.c (original)
+++ trunk/comar/comar/src/notify.c Thu Oct 4 15:06:25 2007
@@ -20,11 +20,10 @@
void *
notify_alloc(void)
{
-· /*!
-· Allocates memory for notifies and returns pointer to allocated memory
-· Returns Null on error.
-· */
-
+ /*!
+ Allocates memory for notifies and returns pointer to allocated memory
+ Returns Null on error.
+ */
int size;
size = (model_max_notifications + 7)/ 8;
Modified: trunk/comar/comar/src/process.c
=================================================================
--- trunk/comar/comar/src/process.c (original)
+++ trunk/comar/comar/src/process.c Thu Oct 4 15:06:25 2007
@@ -40,14 +40,14 @@
struct sigaction dfl;
act.sa_handler = handle_sigterm;
- /*! initialize and empty a signal set. Signals are to be blocked while executing handle_sigterm */
+ /*! initialize and empty a signal set. Signals are to be blocked while executing handle_sigterm */
sigemptyset(&act.sa_mask);
act.sa_flags = 0; /*!< special flags */
ign.sa_handler = SIG_IGN;
sigemptyset(&ign.sa_mask);
ign.sa_flags = 0;
-
+
dfl.sa_handler = SIG_DFL; /*!< default signal handling. */
sigemptyset(&dfl.sa_mask);
dfl.sa_flags = 0;
@@ -96,15 +96,14 @@
return &my_proc.children[0];
}
-//! Add a child
+//! add a child
static struct ProcChild *
add_child(pid_t pid, int to, int from, const char *desc)
{
-· /*!
-· Adds a child process with given arguments to process
-· @return Returns added child process
-· */
-
+ /*!
+ Adds a child process with given arguments to process
+ @return Returns added child process
+ */
int i;
i = my_proc.nr_children;
@@ -148,11 +147,10 @@
static void
stop_children(void)
{
-· /*!
-· Send SIGTERM to all child processes, wait for 3 seconds
-· if they resist, kill'em all
-· */
-
+ /*!
+ Send SIGTERM to all child processes, wait for 3 seconds
+ if they resist, kill'em all
+ */
struct timeval start;
struct timeval cur;
struct timeval tv;
@@ -229,14 +227,13 @@
struct ProcChild *
proc_fork(void (*child_func)(void), const char *desc)
{
-· /*!
-· Child process fork function, child process continues from child_func
-· \param desc is description, process name
-· @return Returns Null on error
-· */
-
+ /*!
+ Child process fork function, child process continues from child_func
+ \param desc is description, process name
+ @return Returns Null on error
+ */
pid_t pid;
- int fdr[2], fdw[2];
+ int fdr[2], fdw[2]; // file descriptors to read and write from pipe
int i;
pipe(fdr);
@@ -244,7 +241,7 @@
pid = fork();
if (pid == -1) return NULL;
- if (pid == 0) {
+ if (pid == 0) { // child process
// new child process starts
// we have to close unneeded pipes inherited from the parent
if (my_proc.parent.to != -1) close(my_proc.parent.to);
@@ -310,12 +307,11 @@
int
proc_select_fds(fd_set *fds, int max, struct ProcChild **senderp, int *cmdp, size_t *sizep, int timeout)
{
-· /*!
-· Listen incoming requests with 'select()'
-· Sets command, data size and returns 1 if there's something to listen
-· Returns 0 otherwise
-· */
-
+ /*!
+ Listen incoming requests with 'select()'
+ Sets command, data size and returns 1 if there's something to listen
+ Returns 0 otherwise
+ */
unsigned int ipc;
struct timeval tv, *tvptr;
int sock;
Modified: trunk/comar/comar/src/rpc_unix.c
=================================================================
--- trunk/comar/comar/src/rpc_unix.c (original)
+++ trunk/comar/comar/src/rpc_unix.c Thu Oct 4 15:06:25 2007
@@ -104,25 +104,24 @@
static int
create_pipe(const char *pipe_name)
{
-· /*!
-· Creates a pipe, with listen. length of the queue is 5
-· @return Returns -2 if can't assign address to socket \n
-· Returns -3 if can't listen requests
-· */
-
+ /*!
+ Creates a pipe, with listen. length of the queue is 5
+ @return Returns -2 if can't assign address to socket \n
+ Returns -3 if can't listen requests
+ */
struct sockaddr_un name;
size_t size;
pipe_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
if (pipe_fd < 0) return -1;
- // delete cfg_socket_name
+ // delete cfg_socket_name
unlink(pipe_name);
name.sun_family = AF_LOCAL;
strncpy(name.sun_path, pipe_name, sizeof(name.sun_path));
size = (offsetof(struct sockaddr_un, sun_path) + strlen(name.sun_path) + 1);
- // assign address to socket
+ // assign address to socket
if (0 != bind(pipe_fd, (struct sockaddr *) &name, size)) {
close(pipe_fd);
return -2;
@@ -130,7 +129,7 @@
chmod(pipe_name, 0666);
- // to enable connection requests on the socket ( a server socket )
+ // to enable connection requests on the socket ( a server socket )
if (0 != listen(pipe_fd, 5)) {
close(pipe_fd);
return -3;
@@ -143,10 +142,10 @@
static int
get_peer(int sock, struct Creds *cred)
{
-· /*!
-· Gets options of sock, and fills cred according to these options
-· @return Returns 0. Returns -1 on error.
-· */
+ /*!
+ Gets options of sock, and fills cred according to these options
+ @return Returns 0. Returns -1 on error.
+ */
// NOTE: this implementation requires a linux kernel
struct {
pid_t pid;
@@ -256,10 +255,9 @@
static int
write_rpc(struct connection *c, unsigned int cmd, int id, const char *buffer, size_t size)
{
-· /*!
-· Checks the command cmd, and sends c's socket the answer
-· */
-
+ /*!
+ Checks the command cmd, and sends c's socket the answer
+ */
unsigned char head[8];
head[4] = (id >> 24) & 0xFF;
@@ -300,11 +298,10 @@
static int
parse_rpc(struct connection *c)
{
-· /*!
- This is parser function for RPC
-· According to command in c's buffer, checks for permissions
-· and executes, denies etc. the command
-· */
+ /*! This is parser function for RPC
+ According to command in c's buffer, checks for permissions
+ and executes, denies etc. the command
+ */
struct ipc_struct ipc;
struct arg_s args;
@@ -501,7 +498,7 @@
}
}
if (c->pos == c->data_size + 8) {
- if (parse_rpc(c)) return -1;
+ if (read_rpc(c)) return -1;
c->data_size = 0;
c->pos = 0;
}
@@ -526,7 +523,6 @@
}
return max;
}
-
//! This is handler function for custom rpc commands
void
handle_rpc_fds(fd_set *fds)
@@ -652,11 +648,10 @@
void
rpc_unix_start(void)
{
-· /*!
-· Fork RPC process
-· @return Returns -1 on error
-· */
-
+ /*!
+ Fork RPC process
+ @return Returns -1 on error
+ */
struct ProcChild *p;
p = proc_fork(rpc_proc, "ComarRPC");
Modified: trunk/comar/comar/src/utility.c
=================================================================
--- trunk/comar/comar/src/utility.c (original)
+++ trunk/comar/comar/src/utility.c Thu Oct 4 15:06:25 2007
@@ -19,11 +19,11 @@
unsigned char *
load_file(const char *fname, int *sizeptr)
{
-· /*!
-· Gets file size from stat and allocates enough memory to save file content. \n
-· sizeptr was used while loading compiled form of these scripts to python
-· @return Returns data loaded, or NULL on error
-· */
+ /*!
+ Gets file size from stat and allocates enough memory to save file content. \n
+ sizeptr was used while loading compiled form of these scripts to python
+ @return Returns data loaded, or NULL on error
+ */
FILE *f;
struct stat fs;
@@ -56,11 +56,11 @@
int
save_file(const char *fname, const char *buffer, size_t size)
{
-· /*!
-· @return Returns -1 if file could not be opened for binary writing \n
-· Returns -2 if file could not be written to disc or buffer is empty \n
-· Returns 0 on success
-· */
+ /*!
+ @return Returns -1 if file could not be opened for binary writing \n
+ Returns -2 if file could not be written to disc or buffer is empty \n
+ Returns 0 on success
+ */
FILE *f;
@@ -78,11 +78,11 @@
int
utf8_is_valid(const char *str, size_t size)
{
-· /*!
-· Because not all byte strings are valid, checks every character in string for security reasons
-· i.e for invalid utf8 string 0xC0 0x80 ..
-· @return Returns 1 if is valid, 0 otherwise
-· */
+ /*!
+ Because not all byte strings are valid, checks every character in string for security reasons
+ i.e for invalid utf8 string 0xC0 0x80 ..
+ @return Returns 1 if is valid, 0 otherwise
+ */
int i;
int len = 0;
@@ -96,7 +96,6 @@
// those are not allowed at any point
if (0 == c || 0xFE == c || 0xFF == c) return 0;
-
if (max) {
// we are in a multi byte char
@@ -154,13 +153,12 @@
struct pack *
pack_new(size_t min_size)
{
-· /*!
-· This function creates a pack struct ( described in utility.h )
-· which has a buffer of minimum size of 256 ( or min_size, if is bigger than 256 )
-· @return Returns created pack
-· \sa utility.h
-· */
-
+ /*!
+ This function creates a pack struct ( described in utility.h )
+ which has a buffer of minimum size of 256 ( or min_size, if is bigger than 256 )
+ @return Returns created pack
+ \sa utility.h
+ */
struct pack *p;
p = calloc(sizeof(struct pack), 1);
@@ -179,11 +177,10 @@
struct pack *
pack_wrap(char *buffer, size_t size)
{
-· /*!
-· puts buffer in a pack and returns a pointer to pack,
-· @return Returns Null on error, pointer to pack otherwise
-· */
-
+ /*!
+ puts buffer in a pack and returns a pointer to pack,
+ @return Returns Null on error, pointer to pack otherwise
+ */
struct pack *p;
p = calloc(sizeof(struct pack), 1);
@@ -194,12 +191,11 @@
return p;
}
-//! duplicate a pack
+//! Duplicate a pack
struct pack *
pack_dup(struct pack *oldpak)
{
- /*! @return Returns newly created pack */
-
+ /*! @return Returns newly created pack */
struct pack *p;
p = calloc(sizeof(struct pack), 1);
@@ -266,12 +262,11 @@
int
pack_get(struct pack *p, char **argp, size_t *sizep)
{
-· /*!
-· Writes p's size to sizep, if p is empty argp is set to NULL, else it is set to next data
-· p's position is set to the end of data
-· @return Returns 0 on error, 1 otherwise
-· */
-
+ /*!
+ Writes p's size to sizep, if p is empty argp is set to NULL, else it is set to next data
+ p's position is set to the end of data
+ @return Returns 0 on error, 1 otherwise
+ */
unsigned char *ptr;
size_t size;
@@ -290,15 +285,12 @@
return 1;
}
-//! Replace a package
+//! Replace a package.
void
pack_replace(struct pack *p, const char *arg, const char *value, size_t size)
{
-· /*!
- Replaces a package with arg and value if it matches.
-· If it doesn't match, appends it as a new value
- */
-
+ /*! Replaces a package with arg and value if it matches.
+ If it doesn't match, appends it as a new value */
unsigned char *ptr;
char *t;
size_t ts;
Uludag-commits mesaj listesiyle ilgili
daha fazla bilgi