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