Skip to content
Snippets Groups Projects
Commit 6f062aee authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

pass to auto_stra

parent 9eae7218
No related branches found
No related tags found
No related merge requests found
......@@ -28,13 +28,11 @@ int read_svfile(stralloc *sasv,char const *name,char const *src)
log_flow() ;
int r ;
size_t srclen = strlen(src) ;
size_t namelen = strlen(name) ;
char svtmp[srclen + namelen + 1] ;
memcpy(svtmp,src,srclen) ;
memcpy(svtmp + srclen, name, namelen) ;
svtmp[srclen + namelen] = 0 ;
auto_strings(svtmp, src, name) ;
size_t filesize=file_get_size(svtmp) ;
if (!filesize)
......@@ -44,9 +42,10 @@ int read_svfile(stralloc *sasv,char const *name,char const *src)
if(!r)
log_warnusys_return(LOG_EXIT_ZERO,"open ", svtmp) ;
/** ensure that we have an empty line at the end of the string*/
if (!stralloc_cats(sasv,"\n")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(sasv)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!auto_stra(sasv, "\n"))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
return 1 ;
}
......@@ -13,6 +13,7 @@
*/
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <skalibs/stralloc.h>
......@@ -23,21 +24,18 @@ int set_livedir(stralloc *live)
{
log_flow() ;
if (live->len)
{
if (live->s[0] != '/') return -1 ;
if (live->s[live->len - 2] != '/')
{
if (live->len) {
if (live->s[0] != '/')
return -1 ;
if (live->s[live->len - 2] != '/') {
live->len-- ;
if (!stralloc_cats(live,"/")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(live)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!auto_stra(live,"/")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
}
}
else
{
if (!stralloc_cats(live,SS_LIVE)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(live)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
}
live->len--;
} else if (!auto_stra(live,SS_LIVE))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
return 1 ;
}
......@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <skalibs/stralloc.h>
#include <skalibs/types.h>
......@@ -36,9 +37,8 @@ int set_livescan(stralloc *scandir,uid_t owner)
size_t ownerlen = uid_fmt(ownerpack,owner) ;
ownerpack[ownerlen] = 0 ;
if (!stralloc_cats(scandir,SS_SCANDIR "/")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_cats(scandir,ownerpack)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(scandir)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
scandir->len--;
if (!auto_stra(scandir,SS_SCANDIR "/", ownerpack))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
return 1 ;
}
......@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <skalibs/types.h>
#include <skalibs/stralloc.h>
......@@ -36,10 +37,8 @@ int set_livestate(stralloc *livestate,uid_t owner)
size_t ownerlen = uid_fmt(ownerpack,owner) ;
ownerpack[ownerlen] = 0 ;
if (!stralloc_cats(livestate,SS_STATE + 1)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_cats(livestate,"/")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_cats(livestate,ownerpack)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(livestate)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
livestate->len--;
if (!auto_stra(livestate,SS_STATE + 1, "/", ownerpack))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
return 1 ;
}
......@@ -17,6 +17,7 @@
#include <pwd.h>
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <skalibs/stralloc.h>
......@@ -39,9 +40,8 @@ int set_ownerhome(stralloc *base,uid_t owner)
errno = e ;
if (!user_home) return 0 ;
if (!stralloc_cats(base,user_home)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_cats(base,"/")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(base)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
base->len--;
if (!auto_stra(base,user_home, "/"))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
return 1 ;
}
......@@ -16,6 +16,7 @@
#include <errno.h>
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <skalibs/stralloc.h>
......@@ -39,17 +40,15 @@ int set_ownersysdir(stralloc *base, uid_t owner)
errno = e ;
if (user_home == NULL) return 0 ;
if(owner > 0){
if (!stralloc_cats(base,user_home)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_cats(base,"/")) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_cats(base,SS_USER_DIR)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(base)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
}
else
{
if (!stralloc_cats(base,SS_SYSTEM_DIR)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if (!stralloc_0(base)) log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
if(owner > 0) {
if (!auto_stra(base,user_home, "/", SS_USER_DIR))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
} else {
if (!auto_stra(base,SS_SYSTEM_DIR))
log_warnsys_return(LOG_EXIT_ZERO,"stralloc") ;
}
base->len--;
return 1 ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment